diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index ac083fb1b..bf2b05532 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -181,8 +181,6 @@ class ArgumentsAnalyzer if (($arg->value instanceof PhpParser\Node\Expr\Closure || $arg->value instanceof PhpParser\Node\Expr\ArrowFunction) - && $template_result - && $template_result->lower_bounds && $param && !$arg->value->getDocComment() ) { @@ -191,7 +189,7 @@ class ArgumentsAnalyzer $args, $method_id, $context, - $template_result, + $template_result ?? new TemplateResult([], []), $argument_offset, $arg, $param diff --git a/tests/CallableTest.php b/tests/CallableTest.php index 83b42fff4..c0abc4459 100644 --- a/tests/CallableTest.php +++ b/tests/CallableTest.php @@ -63,6 +63,28 @@ class CallableTest extends TestCase 'error_levels' => [], '7.4', ], + 'inferArgFromClassContext' => [ + ' $a + $b);', + 'assertions' => [ + '$a' => 'int', + ], + 'error_levels' => [], + '7.4', + ], 'varReturnType' => [ '