diff --git a/src/Parser/ArrowFunctionArgVisitor.php b/src/Parser/ArrowFunctionArgVisitor.php index 83c20968e4..24b04718fa 100644 --- a/src/Parser/ArrowFunctionArgVisitor.php +++ b/src/Parser/ArrowFunctionArgVisitor.php @@ -13,8 +13,8 @@ class ArrowFunctionArgVisitor extends NodeVisitorAbstract public function enterNode(Node $node): ?Node { - if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Expr\ArrowFunction) { - $args = $node->getRawArgs(); + if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Expr\ArrowFunction && !$node->isFirstClassCallable()) { + $args = $node->getArgs(); if (count($args) > 0) { $node->name->setAttribute(self::ATTRIBUTE_NAME, $args); diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index bf05ba3426..6ec2ed2197 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -988,6 +988,12 @@ public function testBug8078(): void $this->assertNoErrors($errors); } + public function testBug8072(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-8072.php'); + $this->assertNoErrors($errors); + } + /** * @param string[]|null $allAnalysedFiles * @return Error[] diff --git a/tests/PHPStan/Analyser/data/bug-8072.php b/tests/PHPStan/Analyser/data/bug-8072.php new file mode 100644 index 0000000000..8b1c0a0b90 --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-8072.php @@ -0,0 +1,13 @@ + 'Hi'); + echo say((fn (string $name = null) => 'Hi')(...)); +};