@@ -1449,9 +1449,11 @@ private function processStmtNode(
1449
1449
$ exitPointsForOuterLoop = [];
1450
1450
$ throwPoints = $ condResult ->getThrowPoints ();
1451
1451
$ impurePoints = $ condResult ->getImpurePoints ();
1452
+ $ fullCondExpr = null ;
1452
1453
foreach ($ stmt ->cases as $ caseNode ) {
1453
1454
if ($ caseNode ->cond !== null ) {
1454
1455
$ condExpr = new BinaryOp \Equal ($ stmt ->cond , $ caseNode ->cond );
1456
+ $ fullCondExpr = $ fullCondExpr === null ? $ condExpr : new BooleanOr ($ fullCondExpr , $ condExpr );
1455
1457
$ caseResult = $ this ->processExprNode ($ stmt , $ caseNode ->cond , $ scopeForBranches , $ nodeCallback , ExpressionContext::createDeep ());
1456
1458
$ scopeForBranches = $ caseResult ->getScope ();
1457
1459
$ hasYield = $ hasYield || $ caseResult ->hasYield ();
@@ -1460,6 +1462,7 @@ private function processStmtNode(
1460
1462
$ branchScope = $ caseResult ->getTruthyScope ()->filterByTruthyValue ($ condExpr );
1461
1463
} else {
1462
1464
$ hasDefaultCase = true ;
1465
+ $ fullCondExpr = null ;
1463
1466
$ branchScope = $ scopeForBranches ;
1464
1467
}
1465
1468
@@ -1481,8 +1484,9 @@ private function processStmtNode(
1481
1484
if ($ branchScopeResult ->isAlwaysTerminating ()) {
1482
1485
$ alwaysTerminating = $ alwaysTerminating && $ branchFinalScopeResult ->isAlwaysTerminating ();
1483
1486
$ prevScope = null ;
1484
- if (isset ($ condExpr )) {
1485
- $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ condExpr );
1487
+ if (isset ($ fullCondExpr )) {
1488
+ $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ fullCondExpr );
1489
+ $ fullCondExpr = null ;
1486
1490
}
1487
1491
if (!$ branchFinalScopeResult ->isAlwaysTerminating ()) {
1488
1492
$ finalScope = $ branchScope ->mergeWith ($ finalScope );
0 commit comments