Skip to content

Commit

Permalink
Prevent overly greedy $scope->getType() calls in ExistingClassInInsta…
Browse files Browse the repository at this point in the history
…nceOfRule
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 13, 2022
1 parent d5a8d9e commit 93a741e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Rules/Classes/ExistingClassInInstanceOfRule.php
Expand Up @@ -77,9 +77,10 @@ public function processNode(Node $node, Scope $scope): array
}

$classReflection = $this->reflectionProvider->getClass($name);
$expressionType = $scope->getType($node->expr);

if ($classReflection->isTrait()) {
$expressionType = $scope->getType($node->expr);

$errors[] = RuleErrorBuilder::message(sprintf(
'Instanceof between %s and trait %s will always evaluate to false.',
$expressionType->describe(VerbosityLevel::typeOnly()),
Expand Down

0 comments on commit 93a741e

Please sign in to comment.