-
-
Notifications
You must be signed in to change notification settings - Fork 440
[Renaming] Remove Scope filling from Name node on PHPStanNodeScopeResolver for RenameClassRector #4422
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
Merged
Merged
[Renaming] Remove Scope filling from Name node on PHPStanNodeScopeResolver for RenameClassRector #4422
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e3c4a47
[Renaming] Remove Scope filling from Name node on PHPStanNodeScopeRes…
samsonasik 9db64f1
[ci-review] Rector Rectify
actions-user 4fc3761
[ci-review] Rector Rectify
actions-user 7123baa
clean up
samsonasik 9927069
[ci-review] Rector Rectify
actions-user b0eaced
avoid too deep scope filling
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
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
9 changes: 9 additions & 0 deletions
9
...ClassMethod/OptionalParametersAfterRequiredRector/Fixture/skip_variable_variable3.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,9 @@ | ||
| <?php | ||
|
|
||
| abstract class SkipVariableVariable3 | ||
| { | ||
| private static function loadCurveByParam(\DOMXPath $xpath) | ||
| { | ||
| $$param = $$bar = self::decodeValue($result::$item(0)::$textContent); | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...ClassMethod/OptionalParametersAfterRequiredRector/Fixture/skip_variable_variable4.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,9 @@ | ||
| <?php | ||
|
|
||
| abstract class SkipVariableVariable4 | ||
| { | ||
| private static function loadCurveByParam(\DOMXPath $xpath) | ||
| { | ||
| $$param = $$bar = self::decodeValue($result->getItem()->getTextContent()); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,10 @@ public function resolveScope( | |
| return $this->scopeFactory->createFromFile($filePath); | ||
| } | ||
|
|
||
| if ($node->getAttribute(AttributeKey::EXPRESSION_DEPTH) >= 2) { | ||
| return $this->scopeFactory->createFromFile($filePath); | ||
| } | ||
|
Comment on lines
+52
to
+54
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TomasVotruba this is to avoid too deep scope filing assign -> assign -> expr -> method call -> property fetch , eg: $$param = $$bar = self::decodeValue($result->getItem()->getTextContent());that can goes out of control,. |
||
|
|
||
| /** | ||
| * Node and parent Node doesn't has Scope, and Node Start token pos is < 0, | ||
| * it means the node and parent node just re-printed, the Scope need to be resolved from file | ||
|
|
||
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.
shouldn't the scope passed in from rector core be the same as the one in the attribute?
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 still find why
Scopefor RenameClassRector after refactor requireORIGINAL_NODEinstead of Node itself atrector-src/src/Rector/AbstractRector.php
Lines 342 to 343 in 3fa4bec
that's possibly due to docblock is too late to get
Scope, that's another PR to apply if possible ;)