@@ -335,7 +335,9 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
335335 ExpressionContext::createTopLevel (),
336336 );
337337 $ armScope = $ armResult ->getScope ();
338- $ armBodyScopes [] = $ armScope ;
338+ if (!$ armResult ->isAlwaysTerminating ()) {
339+ $ armBodyScopes [] = $ armScope ;
340+ }
339341 $ hasYield = $ hasYield || $ armResult ->hasYield ();
340342 $ throwPoints = array_merge ($ throwPoints , $ armResult ->getThrowPoints ());
341343 $ impurePoints = array_merge ($ impurePoints , $ armResult ->getImpurePoints ());
@@ -372,7 +374,9 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
372374 $ hasYield = $ hasYield || $ armResult ->hasYield ();
373375 $ throwPoints = array_merge ($ throwPoints , $ armResult ->getThrowPoints ());
374376 $ impurePoints = array_merge ($ impurePoints , $ armResult ->getImpurePoints ());
375- $ armBodyScopes [] = $ matchScope ;
377+ if (!$ armResult ->isAlwaysTerminating ()) {
378+ $ armBodyScopes [] = $ matchScope ;
379+ }
376380 continue ;
377381 }
378382
@@ -423,7 +427,9 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
423427 ExpressionContext::createTopLevel (),
424428 );
425429 $ armScope = $ armResult ->getScope ();
426- $ armBodyScopes [] = $ armScope ;
430+ if (!$ armResult ->isAlwaysTerminating ()) {
431+ $ armBodyScopes [] = $ armScope ;
432+ }
427433 $ hasYield = $ hasYield || $ armResult ->hasYield ();
428434 $ throwPoints = array_merge ($ throwPoints , $ armResult ->getThrowPoints ());
429435 $ impurePoints = array_merge ($ impurePoints , $ armResult ->getImpurePoints ());
0 commit comments