Skip to content

Commit 1f1358d

Browse files
staabmondrejmirtes
authored andcommitted
UselessCastRule: do cheaper check first
1 parent 73c5baa commit 1f1358d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Rules/Cast/UselessCastRule.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public function processNode(Node $node, Scope $scope): array
5555
return $ruleErrorBuilder;
5656
}
5757

58-
$expressionTypeWithoutPhpDoc = $scope->getNativeType($node->expr);
59-
if ($castType->isSuperTypeOf($expressionTypeWithoutPhpDoc)->yes()) {
58+
if (!$this->treatPhpDocTypesAsCertainTip) {
6059
return $ruleErrorBuilder;
6160
}
6261

63-
if (!$this->treatPhpDocTypesAsCertainTip) {
62+
$expressionTypeWithoutPhpDoc = $scope->getNativeType($node->expr);
63+
if ($castType->isSuperTypeOf($expressionTypeWithoutPhpDoc)->yes()) {
6464
return $ruleErrorBuilder;
6565
}
6666

0 commit comments

Comments
 (0)