@@ -161,11 +161,9 @@ public function processNodes(
161161
162162 $ scope = $ formerMutatingScope ?? $ this ->scopeFactory ->createFromFile ($ filePath );
163163
164- $ hasUnreachableStatementNode = false ;
165164 $ nodeCallback = function (Node $ node , MutatingScope $ mutatingScope ) use (
166165 &$ nodeCallback ,
167166 $ filePath ,
168- &$ hasUnreachableStatementNode
169167 ): void {
170168 // the class reflection is resolved AFTER entering to class node
171169 // so we need to get it from the first after this one
@@ -188,7 +186,6 @@ public function processNodes(
188186 // so node to be checked inside
189187 if ($ node instanceof UnreachableStatementNode) {
190188 $ this ->processUnreachableStatementNode ($ node , $ filePath , $ mutatingScope );
191- $ hasUnreachableStatementNode = true ;
192189 return ;
193190 }
194191
@@ -410,12 +407,7 @@ public function processNodes(
410407 RectorNodeScopeResolver::processNodes ($ stmts , $ scope );
411408 }
412409
413- if (! $ hasUnreachableStatementNode ) {
414- return $ stmts ;
415- }
416-
417- $ nodeTraverser = new NodeTraverser (new UnreachableStatementNodeVisitor ($ this , $ filePath , $ scope ));
418- return $ nodeTraverser ->traverse ($ stmts );
410+ return $ stmts ;
419411 }
420412
421413 private function processYield (Yield_ $ yield , MutatingScope $ mutatingScope ): void
@@ -591,7 +583,7 @@ private function processUnreachableStatementNode(
591583 $ originalStmt ->setAttribute (AttributeKey::IS_UNREACHABLE , true );
592584 $ originalStmt ->setAttribute (AttributeKey::SCOPE , $ mutatingScope );
593585
594- $ this ->processNodes ([$ originalStmt ], $ filePath , $ mutatingScope );
586+ $ this ->processNodes (array_merge ( [$ originalStmt ], $ unreachableStatementNode -> getNextStatements ()) , $ filePath , $ mutatingScope );
595587 }
596588
597589 /**
0 commit comments