@@ -4090,6 +4090,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
40904090 $ hasDefaultCond = false ;
40914091 $ hasAlwaysTrueCond = false ;
40924092 $ arms = $ expr ->arms ;
4093+ $ armCondsToSkip = [];
40934094 if ($ condType ->isEnum ()->yes ()) {
40944095 // enum match analysis would work even without this if branch
40954096 // but would be much slower
@@ -4110,7 +4111,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
41104111 $ condNodes = [];
41114112 $ conditionCases = [];
41124113 $ conditionExprs = [];
4113- foreach ($ arm ->conds as $ cond ) {
4114+ foreach ($ arm ->conds as $ j => $ cond ) {
41144115 if (!$ cond instanceof Expr \ClassConstFetch) {
41154116 continue 2 ;
41164117 }
@@ -4170,6 +4171,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
41704171 $ conditionExprs [] = $ cond ;
41714172
41724173 unset($ unusedIndexedEnumCases [$ loweredFetchedClassName ][$ caseName ]);
4174+ $ armCondsToSkip [$ i ][$ j ] = true ;
41734175 }
41744176
41754177 $ conditionCasesCount = count ($ conditionCases );
@@ -4246,7 +4248,10 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
42464248 $ filteringExprs = [];
42474249 $ armCondScope = $ matchScope ;
42484250 $ condNodes = [];
4249- foreach ($ arm ->conds as $ armCond ) {
4251+ foreach ($ arm ->conds as $ j => $ armCond ) {
4252+ if (isset ($ armCondsToSkip [$ i ][$ j ])) {
4253+ continue ;
4254+ }
42504255 $ condNodes [] = new MatchExpressionArmCondition ($ armCond , $ armCondScope , $ armCond ->getStartLine ());
42514256 $ armCondResult = $ this ->processExprNode ($ stmt , $ armCond , $ armCondScope , $ storage , $ nodeCallback , $ deepContext );
42524257 $ hasYield = $ hasYield || $ armCondResult ->hasYield ();
0 commit comments