@@ -1449,9 +1449,11 @@ private function processStmtNode(
14491449 $ exitPointsForOuterLoop = [];
14501450 $ throwPoints = $ condResult ->getThrowPoints ();
14511451 $ impurePoints = $ condResult ->getImpurePoints ();
1452+ $ fullCondExpr = null ;
14521453 foreach ($ stmt ->cases as $ caseNode ) {
14531454 if ($ caseNode ->cond !== null ) {
14541455 $ condExpr = new BinaryOp \Equal ($ stmt ->cond , $ caseNode ->cond );
1456+ $ fullCondExpr = $ fullCondExpr === null ? $ condExpr : new BooleanOr ($ fullCondExpr , $ condExpr );
14551457 $ caseResult = $ this ->processExprNode ($ stmt , $ caseNode ->cond , $ scopeForBranches , $ nodeCallback , ExpressionContext::createDeep ());
14561458 $ scopeForBranches = $ caseResult ->getScope ();
14571459 $ hasYield = $ hasYield || $ caseResult ->hasYield ();
@@ -1460,6 +1462,7 @@ private function processStmtNode(
14601462 $ branchScope = $ caseResult ->getTruthyScope ()->filterByTruthyValue ($ condExpr );
14611463 } else {
14621464 $ hasDefaultCase = true ;
1465+ $ fullCondExpr = null ;
14631466 $ branchScope = $ scopeForBranches ;
14641467 }
14651468
@@ -1481,8 +1484,9 @@ private function processStmtNode(
14811484 if ($ branchScopeResult ->isAlwaysTerminating ()) {
14821485 $ alwaysTerminating = $ alwaysTerminating && $ branchFinalScopeResult ->isAlwaysTerminating ();
14831486 $ prevScope = null ;
1484- if (isset ($ condExpr )) {
1485- $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ condExpr );
1487+ if (isset ($ fullCondExpr )) {
1488+ $ scopeForBranches = $ scopeForBranches ->filterByFalseyValue ($ fullCondExpr );
1489+ $ fullCondExpr = null ;
14861490 }
14871491 if (!$ branchFinalScopeResult ->isAlwaysTerminating ()) {
14881492 $ finalScope = $ branchScope ->mergeWith ($ finalScope );
0 commit comments