Skip to content

Commit

Permalink
Cheap checks first in TypeSpecifier
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 13, 2022
1 parent 0962e97 commit 2092177
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Analyser/TypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ public function specifyTypesInCondition(
$exprLeftType = $scope->getType($expr->left);
$exprRightType = $scope->getType($expr->right);
if (
($exprLeftType instanceof ConstantType && !$exprRightType->equals($exprLeftType) && $exprRightType->isSuperTypeOf($exprLeftType)->yes())
|| $exprLeftType instanceof ConstantScalarType
$exprLeftType instanceof ConstantScalarType
|| $exprLeftType instanceof EnumCaseObjectType
|| ($exprLeftType instanceof ConstantType && !$exprRightType->equals($exprLeftType) && $exprRightType->isSuperTypeOf($exprLeftType)->yes())
) {
$types = $this->create(
$expr->right,
Expand All @@ -245,9 +245,9 @@ public function specifyTypesInCondition(
);
}
if (
($exprRightType instanceof ConstantType && !$exprLeftType->equals($exprRightType) && $exprLeftType->isSuperTypeOf($exprRightType)->yes())
|| $exprRightType instanceof ConstantScalarType
$exprRightType instanceof ConstantScalarType
|| $exprRightType instanceof EnumCaseObjectType
|| ($exprRightType instanceof ConstantType && !$exprLeftType->equals($exprRightType) && $exprLeftType->isSuperTypeOf($exprRightType)->yes())
) {
$leftType = $this->create(
$expr->left,
Expand Down

0 comments on commit 2092177

Please sign in to comment.