From d3324b42fa996bcf4b5a532086c0777153679e04 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Wed, 9 Jan 2019 08:49:02 -0500 Subject: [PATCH] Remove slashes from is_a and is_subclass_of string classes, and scan them --- src/Psalm/Internal/Codebase/Scanner.php | 4 ++++ src/Psalm/Internal/Visitor/ReflectorVisitor.php | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php index c1061b93a..5cbe3c385 100644 --- a/src/Psalm/Internal/Codebase/Scanner.php +++ b/src/Psalm/Internal/Codebase/Scanner.php @@ -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 diff --git a/src/Psalm/Internal/Visitor/ReflectorVisitor.php b/src/Psalm/Internal/Visitor/ReflectorVisitor.php index e65ae12d9..cbaf8bbd2 100644 --- a/src/Psalm/Internal/Visitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/Visitor/ReflectorVisitor.php @@ -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;