From 5ef595cc9e2beca842a91f127877b77d23c82597 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 8 Jun 2025 11:25:52 +0200 Subject: [PATCH] UselessCastRule: do cheaper check first --- src/Rules/Cast/UselessCastRule.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Rules/Cast/UselessCastRule.php b/src/Rules/Cast/UselessCastRule.php index ca8f226..6629750 100644 --- a/src/Rules/Cast/UselessCastRule.php +++ b/src/Rules/Cast/UselessCastRule.php @@ -55,12 +55,12 @@ public function processNode(Node $node, Scope $scope): array return $ruleErrorBuilder; } - $expressionTypeWithoutPhpDoc = $scope->getNativeType($node->expr); - if ($castType->isSuperTypeOf($expressionTypeWithoutPhpDoc)->yes()) { + if (!$this->treatPhpDocTypesAsCertainTip) { return $ruleErrorBuilder; } - if (!$this->treatPhpDocTypesAsCertainTip) { + $expressionTypeWithoutPhpDoc = $scope->getNativeType($node->expr); + if ($castType->isSuperTypeOf($expressionTypeWithoutPhpDoc)->yes()) { return $ruleErrorBuilder; }