Skip to content

[Traverser] Add GlobalVariableNodeVisitor#3816

Merged
TomasVotruba merged 6 commits intomainfrom
add-global-variable-vi
May 13, 2023
Merged

[Traverser] Add GlobalVariableNodeVisitor#3816
TomasVotruba merged 6 commits intomainfrom
add-global-variable-vi

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@samsonasik samsonasik commented May 13, 2023

@TomasVotruba @staabm this is Node flag true or false example that I meant. For this PR, is to detect that variable may be a global variable.

$variable = 'value';

function foo()
{
       global $variable;

       echo $variable;
}

The detection is by create new GlobalVariableNodeVariableVisitor by loop the StmtsAwareInterface stmts if there is Global_ stmt, then check on next stmt on loop.

This implementation is currently for Global detection on VariableAnalyzer

https://github.com/rectorphp/rector-src/pull/3816/files#diff-8b66a0350e903758d4d9cc4e625a0383881d1830a878ed3d37d3cbec801bce1c

if this is accepted, we can create detection for static one so no more findFirstPrevious() for this detection.

@samsonasik samsonasik requested a review from TomasVotruba as a code owner May 13, 2023 09:02
@samsonasik samsonasik changed the title [Traverser] Add GlobalVariableNodeVariableVisitor [Traverser] Add GlobalVariableNodeVisitor May 13, 2023
@samsonasik samsonasik force-pushed the add-global-variable-vi branch from c142e9e to 8222b0b Compare May 13, 2023 09:05
@samsonasik
Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba commented May 13, 2023

Thank you, this looks good to go 👍

@TomasVotruba TomasVotruba merged commit 0d3a9a2 into main May 13, 2023
@TomasVotruba TomasVotruba deleted the add-global-variable-vi branch May 13, 2023 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants