Skip to content

[AutoImport] Optimize ClassRenamingPostRector with stop on enterNode()#7295

Merged
samsonasik merged 2 commits intomainfrom
stop-on-enter-node-class-renamign
Sep 16, 2025
Merged

[AutoImport] Optimize ClassRenamingPostRector with stop on enterNode()#7295
samsonasik merged 2 commits intomainfrom
stop-on-enter-node-class-renamign

Conversation

@samsonasik
Copy link
Member

similar with PR:

the process already done on beforeTraverse()

We stop the traversal because all the work has already been done in the beforeTraverse() function

Using STOP_TRAVERSAL is usually dangerous as it will stop the processing of all your nodes for all visitors
but since the PostFileProcessor is using direct new NodeTraverser() and traverse() for only a single
visitor per execution, using stop traversal here is safe,

ref

$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor($postRector);
$stmts = $nodeTraverser->traverse($stmts);

@samsonasik
Copy link
Member Author

samsonasik commented Sep 16, 2025

PHPStan notice seems due to new PHPStan release

https://github.com/phpstan/phpstan/releases/tag/2.1.26

I will fix phpstan notice in separate PR.

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 317ba55 into main Sep 16, 2025
49 checks passed
@samsonasik samsonasik deleted the stop-on-enter-node-class-renamign branch September 16, 2025 13:31
@github-actions
Copy link
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant