1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Remove slashes from is_a and is_subclass_of string classes, and scan them

This commit is contained in:
Matthew Brown 2019-01-09 08:49:02 -05:00
parent 01e41951e7
commit d3324b42fa
2 changed files with 15 additions and 0 deletions

View File

@ -274,6 +274,10 @@ class Scanner
$analyze_too = false,
$store_failure = true
) {
if ($fq_classlike_name[0] === '\\') {
$fq_classlike_name = substr($fq_classlike_name, 1);
}
$fq_classlike_name_lc = strtolower($fq_classlike_name);
// avoid checking classes that we know will just end in failure

View File

@ -342,6 +342,17 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
}
}
if ($function_id === 'is_a' || $function_id === 'is_subclass_of') {
$second_arg = $node->args[1]->value ?? null;
if ($second_arg instanceof PhpParser\Node\Scalar\String_) {
$this->codebase->scanner->queueClassLikeForScanning(
$second_arg->value,
$this->file_path
);
}
}
if ($function_id === 'class_alias') {
$first_arg = $node->args[0]->value ?? null;
$second_arg = $node->args[1]->value ?? null;