Skip to content

Commit 2092177

Browse files
staabmondrejmirtes
authored andcommitted
Cheap checks first in TypeSpecifier
1 parent 0962e97 commit 2092177

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ public function specifyTypesInCondition(
231231
$exprLeftType = $scope->getType($expr->left);
232232
$exprRightType = $scope->getType($expr->right);
233233
if (
234-
($exprLeftType instanceof ConstantType && !$exprRightType->equals($exprLeftType) && $exprRightType->isSuperTypeOf($exprLeftType)->yes())
235-
|| $exprLeftType instanceof ConstantScalarType
234+
$exprLeftType instanceof ConstantScalarType
236235
|| $exprLeftType instanceof EnumCaseObjectType
236+
|| ($exprLeftType instanceof ConstantType && !$exprRightType->equals($exprLeftType) && $exprRightType->isSuperTypeOf($exprLeftType)->yes())
237237
) {
238238
$types = $this->create(
239239
$expr->right,
@@ -245,9 +245,9 @@ public function specifyTypesInCondition(
245245
);
246246
}
247247
if (
248-
($exprRightType instanceof ConstantType && !$exprLeftType->equals($exprRightType) && $exprLeftType->isSuperTypeOf($exprRightType)->yes())
249-
|| $exprRightType instanceof ConstantScalarType
248+
$exprRightType instanceof ConstantScalarType
250249
|| $exprRightType instanceof EnumCaseObjectType
250+
|| ($exprRightType instanceof ConstantType && !$exprLeftType->equals($exprRightType) && $exprLeftType->isSuperTypeOf($exprRightType)->yes())
251251
) {
252252
$leftType = $this->create(
253253
$expr->left,

0 commit comments

Comments
 (0)