Skip to content

Commit

Permalink
Fix ArrowFunctionArgVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 29, 2022
1 parent 6cd3d5d commit 3758d9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parser/ArrowFunctionArgVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
13 changes: 13 additions & 0 deletions tests/PHPStan/Analyser/data/bug-8072.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Bug8072;

function say(\Closure $bar): string
{
return $bar();
}

function (): void {
echo say(fn (string $name = null) => 'Hi');
echo say((fn (string $name = null) => 'Hi')(...));
};

0 comments on commit 3758d9d

Please sign in to comment.