Skip to content

Conversation

@samsonasik
Copy link
Collaborator

Rector is removing tweak below node usage via:

NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
NodeVisitor::DONT_TRAVERSE_CHILDREN

see PR:

This PR is starter to keep compatible :)

@samsonasik samsonasik changed the title Reduce NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN usage on ArrayToArrGetRector Reduce NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN usage on ArrayToArrGetRector (part 1) Dec 2, 2025
@samsonasik samsonasik changed the title Reduce NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN usage on ArrayToArrGetRector (part 1) Reduce NodeVisitor::DONT_TRAVERSE_* usage on ArrayToArrGetRector (part 1) Dec 2, 2025
@samsonasik
Copy link
Collaborator Author

@GeniJaho @driftingly Ready to merge 👍

It will take multiple PRs as there are many usage of it in this repo, this is for starter :)

@peterfox
Copy link
Collaborator

peterfox commented Dec 3, 2025

Is the idea to now use NodeVisitors to mark nodes instead of stopping transversal from what I can see in that PR you mentioned @samsonasik ?

@peterfox peterfox merged commit 2ee7405 into driftingly:main Dec 3, 2025
5 checks passed
@peterfox peterfox added the refactor Pull Request is for the purpose of improvement but not necessarily a change in functionality label Dec 3, 2025
@samsonasik samsonasik deleted the reduce-dont-traver branch December 3, 2025 01:09
@samsonasik
Copy link
Collaborator Author

@peterfox I am thinking of set flag attribute via beforeTraverse() on each rule that needs it, I will create next PR :)

@samsonasik
Copy link
Collaborator Author

@peterfox the stop traversal only works on single visitor (eg: callable traverser).

On rector rules, it will stop immediatelly the loop without next rule, so the attribute flag is the way to go.

@peterfox
Copy link
Collaborator

peterfox commented Dec 3, 2025

@peterfox I am thinking of set flag attribute via beforeTraverse() on each rule that needs it, I will create next PR :)

Okay, do you have any examples I can look at?

@samsonasik
Copy link
Collaborator Author

I on mobile, will create PR here today, for reuse here, custom node visitor decorate maybe needed.

@samsonasik
Copy link
Collaborator Author

@peterfox here usage on beforeTraverse() :)

@peterfox
Copy link
Collaborator

peterfox commented Dec 3, 2025

@samsonasik great. So essentially all nodes can be examined with beforeTraverse, then add the attributes to node which might be problematic etc. and need skipping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull Request is for the purpose of improvement but not necessarily a change in functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants