From bc181de1b86db20ac9c5e9a6825a48076a27229f Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 28 Jul 2025 19:44:44 +0200 Subject: [PATCH 1/2] Try --- src/Analyser/MutatingScope.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } From ce341b46a807683aa47ca8024d86c6b2071ef827 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 28 Jul 2025 20:06:10 +0200 Subject: [PATCH 2/2] Add test --- tests/PHPStan/Analyser/nsrt/bug-13296.php | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/PHPStan/Analyser/nsrt/bug-13296.php 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 ''; + } +}