-
-
Notifications
You must be signed in to change notification settings - Fork 356
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
[Naming] Remove matchesStringName() check completely from NodeNameResolver, including endsWith() method - use getName() and compare directly instead #4954
Conversation
bea1813
to
7ebaf11
Compare
rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
Outdated
Show resolved
Hide resolved
rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
Outdated
Show resolved
Hide resolved
rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
Outdated
Show resolved
Hide resolved
rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
Outdated
Show resolved
Hide resolved
rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
Outdated
Show resolved
Hide resolved
rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
Outdated
Show resolved
Hide resolved
*/ | ||
public function endsWith(string $currentName, string $expectedName): bool | ||
public function endsWith(Node $node, string|array $suffix): bool |
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.
Do we need this method at all, or should just use the matchesName(.., 'myname*')
instead?
A caller could even use getName() and invoke start_ or ends_with in its own.
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.
ohh I see. you want todo it the other way arround. drop all regex magic, in case thats good enough for all existing use-cases
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.
You're right. Removing endsWith()
and startsWith()
might make more sense. There are only 5 cases in our whole code base, so I think it would be better choice.
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.
startsWith()
seems already used in rector-phpunit and rector-symfony so that should be changed first
7f2c806
to
6a88d44
Compare
Ready for 2nd round of reviews 🙂 |
@@ -201,27 +201,27 @@ private function isInLoopWithoutContinueOrBreak(If_ $if): bool | |||
private function processReplaceIfs( | |||
If_ $if, | |||
array $conditions, | |||
Return_ $ifNextReturnClone, | |||
Return_ $cloneIffNextReturn, |
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.
are these class renaming changes related to the actual goal of this PR?
if not, separating these would help to focus on whats important
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.
They're result of fixed naming check 👍 The endsWith() was buggy.
...ts/Naming/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/change_bare_property.php.inc
Show resolved
Hide resolved
8ff0d38
to
48ed8a7
Compare
b719538
to
9ec7c18
Compare
18e279b
to
08f3cd7
Compare
Let's ship it 👍 |
@TomasVotruba @staabm it seems cause error on |
@TomasVotruba @staabm also, documentation need to be updated as it no longer works: $this->isName($node->name, 'set*') |
|
Documentation updated at getrector.org PR: |
Based on feedback from @staabm , I got an idea to remove the regexes from naming completely. This would make naming API intuitive and clean.
It's still possible to check any name against regex with
$this->getName($node)
if needed (not recommended though).What do you think? :) cc @staabm @samsonasik
The single fixture would have to be adjusted, or skipped. Underscore rules were removed long time ago and type actually matches there.