Skip to content

Commit

Permalink
Prevent overly greedy $scope->getType() calls 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 2092177 commit 926ec9d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Analyser/TypeSpecifier.php
Expand Up @@ -424,10 +424,6 @@ public function specifyTypesInCondition(
);

} elseif ($expr instanceof Node\Expr\BinaryOp\Smaller || $expr instanceof Node\Expr\BinaryOp\SmallerOrEqual) {
$orEqual = $expr instanceof Node\Expr\BinaryOp\SmallerOrEqual;
$offset = $orEqual ? 0 : 1;
$leftType = $scope->getType($expr->left);
$rightType = $scope->getType($expr->right);

if (
$expr->left instanceof FuncCall
Expand All @@ -452,6 +448,9 @@ public function specifyTypesInCondition(
);
}

$orEqual = $expr instanceof Node\Expr\BinaryOp\SmallerOrEqual;
$offset = $orEqual ? 0 : 1;
$leftType = $scope->getType($expr->left);
$result = new SpecifiedTypes([], [], false, [], $rootExpr);

if (
Expand Down Expand Up @@ -522,6 +521,7 @@ public function specifyTypesInCondition(
}
}

$rightType = $scope->getType($expr->right);
if ($rightType instanceof ConstantIntegerType) {
if ($expr->left instanceof Expr\PostInc) {
$result = $result->unionWith($this->createRangeTypes(
Expand Down

0 comments on commit 926ec9d

Please sign in to comment.