Skip to content

Commit

Permalink
Revert "[Performance] Immediate remove UnreachableStatementNodeVisito…
Browse files Browse the repository at this point in the history
…r object after traverse to avoid re-use in next file (#4417)" (#4418)

This reverts commit 24ce37d.
  • Loading branch information
samsonasik committed Jul 4, 2023
1 parent 24ce37d commit cd3d327
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,13 @@ public function decorateNodesFromFile(File $file, array $stmts): array
$stmts = $this->phpStanNodeScopeResolver->processNodes($stmts, $file->getFilePath());

if ($this->phpStanNodeScopeResolver->hasUnreachableStatementNode()) {
$unreachableStatementNodeVisitor = new UnreachableStatementNodeVisitor(
$this->phpStanNodeScopeResolver,
$file->getFilePath(),
$this->scopeFactory
$this->nodeTraverser->addVisitor(
new UnreachableStatementNodeVisitor(
$this->phpStanNodeScopeResolver,
$file->getFilePath(),
$this->scopeFactory
)
);
$this->nodeTraverser->addVisitor($unreachableStatementNodeVisitor);

$stmts = $this->nodeTraverser->traverse($stmts);

/**
* immediate remove UnreachableStatementNodeVisitor after traverse to avoid
* re-used in nodeTraverser property in next file
*/
$this->nodeTraverser->removeVisitor($unreachableStatementNodeVisitor);

return $stmts;
}

return $this->nodeTraverser->traverse($stmts);
Expand Down

0 comments on commit cd3d327

Please sign in to comment.