1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Check uses before checking functions

This commit is contained in:
Matthew Brown 2016-09-02 16:16:11 -04:00
parent 750d172917
commit 97a8e447d7

View File

@ -81,6 +81,12 @@ class FileChecker implements StatementsSource
// hoist functions to the top
foreach ($stmts as $stmt) {
if ($stmt instanceof PhpParser\Node\Stmt\Use_) {
foreach ($stmt->uses as $use) {
$this->aliased_classes[$use->alias] = implode('\\', $use->name->parts);
}
}
if ($stmt instanceof PhpParser\Node\Stmt\Function_) {
$function_checkers[$stmt->name] = new FunctionChecker($stmt, $this, $file_context->file_name);
}
@ -133,12 +139,6 @@ class FileChecker implements StatementsSource
}
}
else {
if ($stmt instanceof PhpParser\Node\Stmt\Use_) {
foreach ($stmt->uses as $use) {
$this->aliased_classes[$use->alias] = implode('\\', $use->name->parts);
}
}
$leftover_stmts[] = $stmt;
}
}