@@ -1324,8 +1324,8 @@ async fn test_phpdoc_smart_return_prefilled() {
13241324 assert_eq ! ( r. insert_text. as_deref( ) , Some ( "return string" ) ) ;
13251325}
13261326
1327- /// @return with void return type and no return statements should suggest
1328- /// `@return void` as a smart completion .
1327+ /// When a function has an explicit `: void` type hint, `@return` should
1328+ /// not be suggested at all — the type hint speaks for itself .
13291329#[ tokio:: test]
13301330async fn test_phpdoc_smart_return_void_generic ( ) {
13311331 let backend = create_test_backend ( ) ;
@@ -1343,25 +1343,16 @@ async fn test_phpdoc_smart_return_void_generic() {
13431343 let return_item = items
13441344 . iter ( )
13451345 . find ( |i| i. filter_text . as_deref ( ) == Some ( "@return" ) ) ;
1346- // void return with no return statements → suggest @return void
1346+ // Explicit `: void` type hint → @return is not needed
13471347 assert ! (
1348- return_item. is_some( ) ,
1349- "Should suggest @return void for void functions with no return statements"
1350- ) ;
1351- assert_eq ! (
1352- return_item. unwrap( ) . label,
1353- "@return void" ,
1354- "Label should be @return void"
1355- ) ;
1356- assert_eq ! (
1357- return_item. unwrap( ) . insert_text. as_deref( ) ,
1358- Some ( "return void" ) ,
1359- "Insert text should be 'return void'"
1348+ return_item. is_none( ) ,
1349+ "Should NOT suggest @return when `: void` type hint is present. Got: {:?}" ,
1350+ return_item. map( |i| & i. label)
13601351 ) ;
13611352}
13621353
1363- /// @return void should NOT be suggested when the void function contains
1364- /// return statements with values ( the void hint is likely wrong) .
1354+ /// When an explicit `: void` type hint is present, `@return` should not
1355+ /// be suggested even if the body contains return statements with values .
13651356#[ tokio:: test]
13661357async fn test_phpdoc_smart_return_void_with_return_value ( ) {
13671358 let backend = create_test_backend ( ) ;
@@ -1383,13 +1374,13 @@ async fn test_phpdoc_smart_return_void_with_return_value() {
13831374 . find ( |i| i. filter_text . as_deref ( ) == Some ( "@return" ) ) ;
13841375 assert ! (
13851376 return_item. is_none( ) ,
1386- "Should NOT suggest @return void when body has return with value . Got: {:?}" ,
1377+ "Should NOT suggest @return when `: void` type hint is present . Got: {:?}" ,
13871378 return_item. map( |i| & i. label)
13881379 ) ;
13891380}
13901381
1391- /// @return void SHOULD be suggested when the void function only has bare
1392- /// `return;` statements (early returns with no value) .
1382+ /// When an explicit `: void` type hint is present, `@return` should not
1383+ /// be suggested even with bare `return;` statements .
13931384#[ tokio:: test]
13941385async fn test_phpdoc_smart_return_void_with_bare_return ( ) {
13951386 let backend = create_test_backend ( ) ;
@@ -1413,10 +1404,10 @@ async fn test_phpdoc_smart_return_void_with_bare_return() {
14131404 . iter ( )
14141405 . find ( |i| i. filter_text . as_deref ( ) == Some ( "@return" ) ) ;
14151406 assert ! (
1416- return_item. is_some( ) ,
1417- "Should suggest @return void when body only has bare return;"
1407+ return_item. is_none( ) ,
1408+ "Should NOT suggest @return when `: void` type hint is present. Got: {:?}" ,
1409+ return_item. map( |i| & i. label)
14181410 ) ;
1419- assert_eq ! ( return_item. unwrap( ) . label, "@return void" ) ;
14201411}
14211412
14221413/// @var should be pre-filled with the property type hint.
0 commit comments