@@ -1515,9 +1515,11 @@ private function processStmtNode(
1515
1515
$ exitPointsForOuterLoop = [];
1516
1516
$ throwPoints = $ condResult ->getThrowPoints ();
1517
1517
$ impurePoints = $ condResult ->getImpurePoints ();
1518
+ $ fullCondExpr = null ;
1518
1519
foreach ($ stmt ->cases as $ caseNode ) {
1519
1520
if ($ caseNode ->cond !== null ) {
1520
1521
$ condExpr = new BinaryOp \Equal ($ stmt ->cond , $ caseNode ->cond );
1522
+ $ fullCondExpr = $ fullCondExpr === null ? $ condExpr : new BooleanOr ($ fullCondExpr , $ condExpr );
1521
1523
$ caseResult = $ this ->processExprNode ($ stmt , $ caseNode ->cond , $ scopeForBranches , $ nodeCallback , ExpressionContext::createDeep ());
1522
1524
$ scopeForBranches = $ caseResult ->getScope ();
1523
1525
$ hasYield = $ hasYield || $ caseResult ->hasYield ();
@@ -1526,6 +1528,7 @@ private function processStmtNode(
1526
1528
$ branchScope = $ caseResult ->getTruthyScope ()->filterByTruthyValue ($ condExpr );
1527
1529
} else {
1528
1530
$ hasDefaultCase = true ;
1531
+ $ fullCondExpr = null ;
1529
1532
$ branchScope = $ scopeForBranches ;
1530
1533
}
1531
1534
@@ -1547,8 +1550,9 @@ private function processStmtNode(
1547
1550
if ($ branchScopeResult ->isAlwaysTerminating ()) {
1548
1551
$ alwaysTerminating = $ alwaysTerminating && $ branchFinalScopeResult ->isAlwaysTerminating ();
1549
1552
$ prevScope = null ;
1550
- if (isset ($ condExpr )) {
1551
- $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ condExpr );
1553
+ if (isset ($ fullCondExpr )) {
1554
+ $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ fullCondExpr );
1555
+ $ fullCondExpr = null ;
1552
1556
}
1553
1557
if (!$ branchFinalScopeResult ->isAlwaysTerminating ()) {
1554
1558
$ finalScope = $ branchScope ->mergeWith ($ finalScope );
0 commit comments