-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
UseImportsTraverser: don't deep traverse #4994
Conversation
@@ -77,6 +79,10 @@ private function traverseForType(array $stmts, callable $callable, int $desiredT | |||
$this->processGroupUse($node, $desiredType, $callable); | |||
} | |||
|
|||
if (!$node instanceof Namespace_) { |
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.
there are 2 top level node:
Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace
PhpParser\Node\Stmt\Namespace_
@@ -77,6 +80,10 @@ private function traverseForType(array $stmts, callable $callable, int $desiredT | |||
$this->processGroupUse($node, $desiredType, $callable); | |||
} | |||
|
|||
if (!$node instanceof Namespace_ && !$node instanceof FileWithoutNamespace) { |
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.
How about just use if else if else
?
if ($node instanceof Use_) {
// ...
} elseif ($node instanceof GroupUse) {
// ...
} else {
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
}
return null;
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.
👍
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.
Looking good, Trigger Rectify needs to be run on rector-src code base after this PR merged to ensure nothing oversight :)
Thank you @staabm |
closes rectorphp/rector#8194
before in codeigniter4
after
-> 10 % faster