Skip to content

Commit 8d86993

Browse files
committed
Only specify types for Variables
This leaves us only the same bugs that were already there.
1 parent 83ed44a commit 8d86993

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,6 @@ public function specifyTypesInCondition(
259259
);
260260
}
261261

262-
$exprLeftType = $scope->getType($expr->left);
263-
$exprRightType = $scope->getType($expr->right);
264-
if ($expr->left instanceof Expr\CallLike && $expr->right instanceof Expr\CallLike && !$exprLeftType instanceof ConstantType && !$exprRightType instanceof ConstantType) {
265-
return new SpecifiedTypes();
266-
}
267-
268262
if ($context->true()) {
269263
$type = TypeCombinator::intersect($scope->getType($expr->right), $scope->getType($expr->left));
270264
$leftTypes = $this->create($expr->left, $type, $context, false, $scope);
@@ -281,6 +275,9 @@ public function specifyTypesInCondition(
281275
return $leftTypes->unionWith($rightTypes);
282276
}
283277

278+
$exprLeftType = $scope->getType($expr->left);
279+
$exprRightType = $scope->getType($expr->right);
280+
284281
$types = null;
285282

286283
if (
@@ -321,8 +318,10 @@ public function specifyTypesInCondition(
321318
return $types;
322319
}
323320

324-
return $this->create($expr->left, $exprLeftType, $context, false, $scope)->normalize($scope)
325-
->intersectWith($this->create($expr->right, $exprRightType, $context, false, $scope)->normalize($scope));
321+
if ($expr->left instanceof Expr\Variable && $expr->right instanceof Expr\Variable) {
322+
return $this->create($expr->left, $exprLeftType, $context, false, $scope)->normalize($scope)
323+
->intersectWith($this->create($expr->right, $exprRightType, $context, false, $scope)->normalize($scope));
324+
}
326325
}
327326

328327
} elseif ($expr instanceof Node\Expr\BinaryOp\NotIdentical) {
@@ -357,9 +356,6 @@ public function specifyTypesInCondition(
357356

358357
$leftType = $scope->getType($expr->left);
359358
$rightType = $scope->getType($expr->right);
360-
if ($expr->left instanceof Expr\CallLike && $expr->right instanceof Expr\CallLike && !$leftType instanceof ConstantType && !$rightType instanceof ConstantType) {
361-
return new SpecifiedTypes();
362-
}
363359

364360
$leftBooleanType = $leftType->toBoolean();
365361
if ($leftBooleanType instanceof ConstantBooleanType && $rightType instanceof BooleanType) {

0 commit comments

Comments
 (0)