diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 395626e1ce..4afda9f73f 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -2347,7 +2347,11 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu /** @var non-empty-string $name */ $name = $node->name->value; $functionName = new Name($name); - } elseif ($node->name instanceof FuncCall && $node->name->name instanceof Name) { + } elseif ( + $node->name instanceof FuncCall + && $node->name->name instanceof Name + && $node->name->isFirstClassCallable() + ) { $functionName = $node->name->name; } diff --git a/tests/PHPStan/Analyser/nsrt/bug-13296.php b/tests/PHPStan/Analyser/nsrt/bug-13296.php new file mode 100644 index 0000000000..0a3a5b4318 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/bug-13296.php @@ -0,0 +1,26 @@ + $a + * @param non-empty-array $b + */ + public function test($a, $b) + { + assertType('string', current($a)($b)); + } +} + +class Bar +{ + /** @return string */ + public function __invoke($b) + { + return ''; + } +}