Skip to content

Commit e753dfd

Browse files
committed
Fix ClosureArgVisitor
1 parent 3758d9d commit e753dfd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Parser/ClosureArgVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class ClosureArgVisitor extends NodeVisitorAbstract
1313

1414
public function enterNode(Node $node): ?Node
1515
{
16-
if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Expr\Closure) {
17-
$args = $node->getRawArgs();
16+
if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Expr\Closure && !$node->isFirstClassCallable()) {
17+
$args = $node->getArgs();
1818

1919
if (count($args) > 0) {
2020
$node->name->setAttribute(self::ATTRIBUTE_NAME, $args);

tests/PHPStan/Analyser/data/bug-8072.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ function say(\Closure $bar): string
1010
function (): void {
1111
echo say(fn (string $name = null) => 'Hi');
1212
echo say((fn (string $name = null) => 'Hi')(...));
13+
14+
echo say(function (string $name = null) {
15+
return 'Hi';
16+
});
17+
echo say((function (string $name = null) {
18+
return 'Hi';
19+
})(...));
1320
};

0 commit comments

Comments
 (0)