-
-
Notifications
You must be signed in to change notification settings - Fork 427
[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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7fa9851
[NodeVisitor] Drop ByRefReturnNodeVisitor, check early in only used o…
samsonasik 1391429
temporary pin shipmonk/composer-dependency-analyser to 1.8.3
samsonasik 9f3842b
ignore errors unknown class on build/config/config-downgrade.php
samsonasik 8477688
add outer ref fixture
samsonasik 494ffa9
fix test
samsonasik cb51265
fix
samsonasik 397ac7d
final touch: eol
samsonasik d1b82d9
final touch: early verify only [StmtsAwareInterface::class] to avoid …
samsonasik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ity/Rector/FunctionLike/SimplifyUselessVariableRector/Fixture/return_by_ref_outer.php.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector\Fixture; | ||
|
|
||
| class ReturnByRefOther | ||
| { | ||
| function & test() | ||
| { | ||
| function foo() { | ||
| $var = 9000; | ||
| return $var; | ||
| } | ||
|
|
||
| $var = 9000; | ||
| return $var; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector\Fixture; | ||
|
|
||
| class ReturnByRefOther | ||
| { | ||
| function & test() | ||
| { | ||
| function foo() { | ||
| return 9000; | ||
| } | ||
|
|
||
| $var = 9000; | ||
| return $var; | ||
| } | ||
| } | ||
|
|
||
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefReturnNodeVisitor.php
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
AbstractRectorshould 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.