Skip to content

Commit 1cd9ef9

Browse files
authored
Merge branch refs/heads/2.1.x into 2.2.x
2 parents bb5fd87 + 999d310 commit 1cd9ef9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,14 +1119,20 @@ public function specifyTypesInCondition(
11191119
return $this->specifyTypesInCondition($scope, $expr->expr, $context)->setRootExpr($expr);
11201120
} elseif (
11211121
$expr instanceof Expr\Ternary
1122-
&& !$context->null()
11231122
&& !$expr->cond instanceof Expr\Ternary
1123+
&& !$context->null()
11241124
) {
1125-
$ifExpr = $expr->if ?? $expr->cond;
1126-
$conditionExpr = new BooleanOr(
1127-
new BooleanAnd($expr->cond, $ifExpr),
1128-
new BooleanAnd(new Expr\BooleanNot($expr->cond), $expr->else),
1129-
);
1125+
if ($expr->if !== null) {
1126+
$conditionExpr = new BooleanOr(
1127+
new BooleanAnd($expr->cond, $expr->if),
1128+
new BooleanAnd(new Expr\BooleanNot($expr->cond), $expr->else),
1129+
);
1130+
} else {
1131+
$conditionExpr = new BooleanOr(
1132+
$expr->cond,
1133+
new BooleanAnd(new Expr\BooleanNot($expr->cond), $expr->else),
1134+
);
1135+
}
11301136

11311137
return $this->specifyTypesInCondition($scope, $conditionExpr, $context)->setRootExpr($expr);
11321138

0 commit comments

Comments
 (0)