-
-
Notifications
You must be signed in to change notification settings - Fork 416
[code-quality] Add VariableConstFetchToClassConstFetchRector #7457
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
[code-quality] Add VariableConstFetchToClassConstFetchRector #7457
Conversation
9c5b838 to
c6de4a5
Compare
481eee4 to
4cc11c6
Compare
rules/CodeQuality/Rector/ClassConstFetch/VariableConstFetchToClassConstFetchRector.php
Outdated
Show resolved
Hide resolved
4cc11c6 to
36b2cf4
Compare
| */ | ||
| public function refactor(Node $node): ?ClassConstFetch | ||
| { | ||
| if (! $node->class instanceof Expr) { |
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.
per rule name, I think this needs to be exactly check against Variable node, check on Expr may cause invalid due to side effect call, eg:
some_side_effect()::NAME;I will create new PR to fix it.
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.
Prefer known class, over pseudo-dynamic value:
final class AllowOverride { public function run(KnownClass $classWithConstants) { - return $classWithConstants::SOME_CONSTANT; + return KnownClass::SOME_CONSTANT; } }