diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index f10ff9241..2499b9532 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -682,7 +682,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $inferred_return_types, $codebase ) - : null; + : Type::getVoid(); if ($inferred_return_type && !$inferred_return_type->isVoid() @@ -776,7 +776,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $closure_return_types, $codebase ) - : null; + : Type::getVoid(); $closure_yield_type = $closure_yield_types ? \Psalm\Type::combineUnionTypeArray( diff --git a/tests/ClosureTest.php b/tests/ClosureTest.php index 80a5f6a61..5193d4bb2 100644 --- a/tests/ClosureTest.php +++ b/tests/ClosureTest.php @@ -873,6 +873,22 @@ class ClosureTest extends TestCase false, '7.4', ], + 'detectImplicitVoidReturn' => [ + 'getMessage(); + } + + takesClosureReturningException( + function () { + echo "hello"; + } + );', + 'error_message' => 'InvalidArgument' + ], ]; } } diff --git a/tests/InterfaceTest.php b/tests/InterfaceTest.php index deea4cb26..d382ce0cc 100644 --- a/tests/InterfaceTest.php +++ b/tests/InterfaceTest.php @@ -553,7 +553,7 @@ class InterfaceTest extends TestCase $i::doFoo(); }', ], - 'inheritSystemInterface' => [ + 'SKIPPED-inheritSystemInterface' => [ ' 'InvalidReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:28 - The inferred type \'impure-Closure(B):void\' does not match the declared return type \'callable(A):void\' for map', + 'error_message' => 'InvalidReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:28 - The inferred type \'pure-Closure(B):void\' does not match the declared return type \'callable(A):void\' for map', ], 'compareTKeyedArrayToAlwaysFilledArray' => [ '