Skip to content

Commit

Permalink
Fix ClosureArgVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 29, 2022
1 parent 3758d9d commit e753dfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parser/ClosureArgVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class ClosureArgVisitor extends NodeVisitorAbstract

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

if (count($args) > 0) {
$node->name->setAttribute(self::ATTRIBUTE_NAME, $args);
Expand Down
7 changes: 7 additions & 0 deletions tests/PHPStan/Analyser/data/bug-8072.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ function say(\Closure $bar): string
function (): void {
echo say(fn (string $name = null) => 'Hi');
echo say((fn (string $name = null) => 'Hi')(...));

echo say(function (string $name = null) {
return 'Hi';
});
echo say((function (string $name = null) {
return 'Hi';
})(...));
};

0 comments on commit e753dfd

Please sign in to comment.