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

Fix #1314 - make sure we always know what a closure is if we’re using one

This commit is contained in:
Matthew Brown 2019-02-10 16:23:31 -05:00
parent c58100e3af
commit 9a8f969d5c
2 changed files with 10 additions and 1 deletions

View File

@ -245,6 +245,10 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
} elseif ($node instanceof PhpParser\Node\FunctionLike) { } elseif ($node instanceof PhpParser\Node\FunctionLike) {
$this->registerFunctionLike($node); $this->registerFunctionLike($node);
if ($node instanceof PhpParser\Node\Expr\Closure) {
$this->codebase->scanner->queueClassLikeForScanning('Closure', $this->file_path);
}
if (!$this->scan_deep) { if (!$this->scan_deep) {
return PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; return PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN;
} }

View File

@ -1198,7 +1198,12 @@ class TypeReconciliationTest extends TestCase
$s = rand(0,1) ? "strlen" : [1]; $s = rand(0,1) ? "strlen" : [1];
if (!is_callable($s)) { if (!is_callable($s)) {
array_pop($s); array_pop($s);
}' }
$a = rand(0, 1) ? (function(): void {}) : 1.1;
if (!is_callable($a)) {
echo $a;
}',
], ],
]; ];
} }