-
-
Notifications
You must be signed in to change notification settings - Fork 426
[NodeVisitor] Drop ByRefReturnNodeVisitor, check early in only used once SimplifyUselessVariableRector #7667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
https://github.com/rectorphp/rector-src/actions/runs/19675350225/job/56354827988?pr=7667#step:5:16 seems due to latest release of I created issue for it at: |
|
I temporary pin |
|
All checks have passed 🎉 @TomasVotruba it is ready for review. |
|
I add outher ref fixture test for it that inner should keep applied 73448a4 |
|
All checks have passed 🎉 @TomasVotruba I think it is ready. |
…nce SimplifyUselessVariableRector
d6d136b to
cb51265
Compare
|
Rebased. All checks have passed 🎉 @TomasVotruba I think it is ready. |
…regression as possible
| } | ||
|
|
||
| $subNode->setAttribute(AttributeKey::SKIPPED_BY_RECTOR_RULE, static::class); | ||
| return $subNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like removal of the node traverser above, as we can use the rule directly.
But I'm bit confused by this part. AbstractRector should get slimmer, not bigger.
How can we remove the node traverser and keep this class as small as possible at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That removal of visitor, not traverser.
It cost of return NodeVisitor::DONT_TRAVERSE_CHILDREN, the original functionality is "dont traverse ANY visitor" to visit below node.
On single visitor, eg: callable traverser, it is ok, on rector rules, the tweak is needed as it needs to only skip below node on "current rule", other rules are allowed to visit and apply change, that's why the flag is needed.
I can move the functionality to separate service tho, but flagging node to skip below node still needed, since other still allowed to visit and apply change.
|
Closing for now. |
This PR apply:
Drop
ByRefReturnNodeVisitorthat setis_byref_returnattribute on return when it is insideFunctionLike, this can be handled by returnNodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDRENonrefactor()method when node is instanceofFunctionLikeand it by ref return via:This require change on
AbstractRector::decorateCurrentAndChildren()method, asgetNodeTypes()only define singleStmtsAwareInterface:rector-src/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php
Line 109 in fa54d46
which mean no other types, so it require sub type check of it to skip on current rule passed.
If there are other types defined after it and subnode is equal then other type defined in
getNodeTypes()method, set it to skip, otherwise, verify ifgetNodeTypes()is[StmtsAwareInterface::class]and current node isFunctionLike, then to not apply as requires realidated and no need to apply skip rule flag, then otherwise, apply any child of node of it to skip on current rule only via: