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:
parent
f3d3ef9074
commit
02a58f787b
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user