Skip to content

Commit 93a741e

Browse files
staabmondrejmirtes
authored andcommitted
Prevent overly greedy $scope->getType() calls in ExistingClassInInstanceOfRule
1 parent d5a8d9e commit 93a741e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Rules/Classes/ExistingClassInInstanceOfRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public function processNode(Node $node, Scope $scope): array
7777
}
7878

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

8281
if ($classReflection->isTrait()) {
82+
$expressionType = $scope->getType($node->expr);
83+
8384
$errors[] = RuleErrorBuilder::message(sprintf(
8485
'Instanceof between %s and trait %s will always evaluate to false.',
8586
$expressionType->describe(VerbosityLevel::typeOnly()),

0 commit comments

Comments
 (0)