1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #4148 - add Closure to scanned classes when arrow function is seen

This commit is contained in:
Brown 2020-09-07 11:11:01 -04:00
parent f3d3ef9074
commit 02a58f787b
2 changed files with 15 additions and 1 deletions

View File

@ -330,7 +330,9 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
$this->registerFunctionLike($node);
if ($node instanceof PhpParser\Node\Expr\Closure) {
if ($node instanceof PhpParser\Node\Expr\Closure
|| $node instanceof PhpParser\Node\Expr\ArrowFunction
) {
$this->codebase->scanner->queueClassLikeForScanning('Closure');
}

View File

@ -837,6 +837,18 @@ class ClosureTest extends TestCase
}',
'error_message' => 'MixedReturnStatement'
],
'noCrashWhenComparingIllegitimateCallable' => [
'<?php
class C {}
function foo() : C {
return fn (int $i) => "";
}',
'error_message' => 'InvalidReturnStatement',
[],
[],
'7.4',
],
];
}
}