@@ -253,6 +253,7 @@ public function __construct(
253
253
private readonly ScopeFactory $ scopeFactory ,
254
254
private readonly bool $ polluteScopeWithLoopInitialAssignments ,
255
255
private readonly bool $ polluteScopeWithAlwaysIterableForeach ,
256
+ private readonly bool $ polluteScopeWithBlock ,
256
257
private readonly array $ earlyTerminatingMethodCalls ,
257
258
private readonly array $ earlyTerminatingFunctionCalls ,
258
259
private readonly array $ universalObjectCratesClasses ,
@@ -1895,7 +1896,20 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
1895
1896
new ImpurePoint ($ scope , $ stmt , 'betweenPhpTags ' , 'output between PHP opening and closing tags ' , true ),
1896
1897
];
1897
1898
} elseif ($ stmt instanceof Node \Stmt \Block) {
1898
- return $ this ->processStmtNodes ($ stmt , $ stmt ->stmts , $ scope , $ nodeCallback , $ context );
1899
+ $ result = $ this ->processStmtNodes ($ stmt , $ stmt ->stmts , $ scope , $ nodeCallback , $ context );
1900
+ if ($ this ->polluteScopeWithBlock ) {
1901
+ return $ result ;
1902
+ }
1903
+
1904
+ return new StatementResult (
1905
+ $ scope ->mergeWith ($ result ->getScope ()),
1906
+ $ result ->hasYield (),
1907
+ $ result ->isAlwaysTerminating (),
1908
+ $ result ->getExitPoints (),
1909
+ $ result ->getThrowPoints (),
1910
+ $ result ->getImpurePoints (),
1911
+ $ result ->getEndStatements (),
1912
+ );
1899
1913
} elseif ($ stmt instanceof Node \Stmt \Nop) {
1900
1914
$ hasYield = false ;
1901
1915
$ throwPoints = $ overridingThrowPoints ?? [];
0 commit comments