diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index 6e53f991299..480bbeb3666 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -2037,6 +2037,11 @@ protected static function getInstanceOfTypes( $source->getAliases() ); + if ($source instanceof StatementsAnalyzer) { + $codebase = $source->getCodebase(); + $instanceof_class = $codebase->classlikes->getUnAliasedName($instanceof_class); + } + return [$instanceof_class]; } elseif ($this_class_name && (in_array(strtolower($stmt->class->parts[0]), ['self', 'static'], true)) diff --git a/src/Psalm/Internal/Visitor/ReflectorVisitor.php b/src/Psalm/Internal/Visitor/ReflectorVisitor.php index 3f47deb8562..25922913d01 100644 --- a/src/Psalm/Internal/Visitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/Visitor/ReflectorVisitor.php @@ -349,6 +349,10 @@ public function enterNode(PhpParser\Node $node) $this->registerClassMapFunctionCall($function_id, $node); } } elseif ($node instanceof PhpParser\Node\Stmt\TraitUse) { + if ($this->skip_if_descendants) { + return; + } + if (!$this->classlike_storages) { throw new \LogicException('$this->classlike_storages should not be empty'); }