@@ -1515,9 +1515,11 @@ private function processStmtNode(
15151515 $ exitPointsForOuterLoop = [];
15161516 $ throwPoints = $ condResult ->getThrowPoints ();
15171517 $ impurePoints = $ condResult ->getImpurePoints ();
1518+ $ fullCondExpr = null ;
15181519 foreach ($ stmt ->cases as $ caseNode ) {
15191520 if ($ caseNode ->cond !== null ) {
15201521 $ condExpr = new BinaryOp \Equal ($ stmt ->cond , $ caseNode ->cond );
1522+ $ fullCondExpr = $ fullCondExpr === null ? $ condExpr : new BooleanOr ($ fullCondExpr , $ condExpr );
15211523 $ caseResult = $ this ->processExprNode ($ stmt , $ caseNode ->cond , $ scopeForBranches , $ nodeCallback , ExpressionContext::createDeep ());
15221524 $ scopeForBranches = $ caseResult ->getScope ();
15231525 $ hasYield = $ hasYield || $ caseResult ->hasYield ();
@@ -1526,6 +1528,7 @@ private function processStmtNode(
15261528 $ branchScope = $ caseResult ->getTruthyScope ()->filterByTruthyValue ($ condExpr );
15271529 } else {
15281530 $ hasDefaultCase = true ;
1531+ $ fullCondExpr = null ;
15291532 $ branchScope = $ scopeForBranches ;
15301533 }
15311534
@@ -1547,8 +1550,9 @@ private function processStmtNode(
15471550 if ($ branchScopeResult ->isAlwaysTerminating ()) {
15481551 $ alwaysTerminating = $ alwaysTerminating && $ branchFinalScopeResult ->isAlwaysTerminating ();
15491552 $ prevScope = null ;
1550- if (isset ($ condExpr )) {
1551- $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ condExpr );
1553+ if (isset ($ fullCondExpr )) {
1554+ $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ fullCondExpr );
1555+ $ fullCondExpr = null ;
15521556 }
15531557 if (!$ branchFinalScopeResult ->isAlwaysTerminating ()) {
15541558 $ finalScope = $ branchScope ->mergeWith ($ finalScope );
0 commit comments