Skip to content

Commit 91de2db

Browse files
ondrejmirtesherndlm
authored andcommitted
Simplify TypeSpecifier
1 parent ea4e17e commit 91de2db

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -278,32 +278,28 @@ public function specifyTypesInCondition(
278278
$exprLeftType = $scope->getType($expr->left);
279279
$exprRightType = $scope->getType($expr->right);
280280
if ($exprLeftType instanceof ConstantType || $exprLeftType instanceof EnumCaseObjectType) {
281-
if (!$expr->right instanceof Node\Scalar && !$expr->right instanceof Expr\Array_) {
282-
$types = $this->create(
283-
$expr->right,
284-
$exprLeftType,
285-
$context,
286-
false,
287-
$scope,
288-
$rootExpr,
289-
);
290-
}
281+
$types = $this->create(
282+
$expr->right,
283+
$exprLeftType,
284+
$context,
285+
false,
286+
$scope,
287+
$rootExpr,
288+
);
291289
}
292290
if ($exprRightType instanceof ConstantType || $exprRightType instanceof EnumCaseObjectType) {
293-
if ($types === null || (!$expr->left instanceof Node\Scalar && !$expr->left instanceof Expr\Array_)) {
294-
$leftType = $this->create(
295-
$expr->left,
296-
$exprRightType,
297-
$context,
298-
false,
299-
$scope,
300-
$rootExpr,
301-
);
302-
if ($types !== null) {
303-
$types = $types->unionWith($leftType);
304-
} else {
305-
$types = $leftType;
306-
}
291+
$leftType = $this->create(
292+
$expr->left,
293+
$exprRightType,
294+
$context,
295+
false,
296+
$scope,
297+
$rootExpr,
298+
);
299+
if ($types !== null) {
300+
$types = $types->unionWith($leftType);
301+
} else {
302+
$types = $leftType;
307303
}
308304
}
309305

0 commit comments

Comments
 (0)