Skip to content

Commit 926ec9d

Browse files
staabmondrejmirtes
authored andcommitted
Prevent overly greedy $scope->getType() calls in TypeSpecifier
1 parent 2092177 commit 926ec9d

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
@@ -424,10 +424,6 @@ public function specifyTypesInCondition(
424424
);
425425

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

432428
if (
433429
$expr->left instanceof FuncCall
@@ -452,6 +448,9 @@ public function specifyTypesInCondition(
452448
);
453449
}
454450

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

457456
if (
@@ -522,6 +521,7 @@ public function specifyTypesInCondition(
522521
}
523522
}
524523

524+
$rightType = $scope->getType($expr->right);
525525
if ($rightType instanceof ConstantIntegerType) {
526526
if ($expr->left instanceof Expr\PostInc) {
527527
$result = $result->unionWith($this->createRangeTypes(

0 commit comments

Comments
 (0)