diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php index 3d1a51c4e..14a947f51 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php @@ -288,7 +288,8 @@ final class HighOrderFunctionArgHandler } foreach ($container_param->type->getAtomicTypes() as $a) { - if (($a instanceof TClosure || $a instanceof TCallable) && !$a->params) { + // must check null explicitly, since no params (empty array) would not be handled correctly otherwise + if (($a instanceof TClosure || $a instanceof TCallable) && $a->params === null) { return false; } diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 2b73d6550..b24166f9c 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -2352,6 +2352,18 @@ class FunctionCallTest extends TestCase fooFoo("string");', 'error_message' => 'InvalidScalarArgument', ], + 'invalidArgumentCallableWithoutArgsUnion' => [ + 'code' => ' 'InvalidArgument', + ], 'invalidArgumentWithDeclareStrictTypes' => [ 'code' => '