@@ -184,7 +184,7 @@ public function processNodes(
184184 // early check here as UnreachableStatementNode is special VirtualNode
185185 // so node to be checked inside
186186 if ($ node instanceof UnreachableStatementNode) {
187- $ this ->processUnreachableStatementNode ($ node , $ filePath , $ mutatingScope );
187+ $ this ->processUnreachableStatementNode ($ node , $ mutatingScope , $ nodeCallback );
188188 return ;
189189 }
190190
@@ -573,16 +573,26 @@ private function processTryCatch(TryCatch $tryCatch, MutatingScope $mutatingScop
573573 }
574574 }
575575
576+ /**
577+ * @param callable(Node $node, MutatingScope $scope): void $nodeCallback
578+ */
576579 private function processUnreachableStatementNode (
577580 UnreachableStatementNode $ unreachableStatementNode ,
578- string $ filePath ,
579- MutatingScope $ mutatingScope
581+ MutatingScope $ mutatingScope ,
582+ callable $ nodeCallback
580583 ): void {
581584 $ originalStmt = $ unreachableStatementNode ->getOriginalStatement ();
582585 $ originalStmt ->setAttribute (AttributeKey::IS_UNREACHABLE , true );
583- $ originalStmt ->setAttribute (AttributeKey::SCOPE , $ mutatingScope );
584586
585- $ this ->processNodes (array_merge ([$ originalStmt ], $ unreachableStatementNode ->getNextStatements ()), $ filePath , $ mutatingScope );
587+ foreach ($ unreachableStatementNode ->getNextStatements () as $ nextStatement ) {
588+ $ nextStatement ->setAttribute (AttributeKey::IS_UNREACHABLE , true );
589+ }
590+
591+ $ this ->nodeScopeResolverProcessNodes (
592+ array_merge ([$ originalStmt ], $ unreachableStatementNode ->getNextStatements ()),
593+ $ mutatingScope ,
594+ $ nodeCallback
595+ );
586596 }
587597
588598 /**
0 commit comments