Skip to content
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

NodeNameResolver: Throw exception in BC breaking path #4980

Merged
merged 1 commit into from Sep 11, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 11, 2023

No description provided.

@staabm
Copy link
Contributor Author

staabm commented Sep 11, 2023

the failling build tells me we have still some work left in the codebase to compensate the removal of the regex matching ;)

@samsonasik
Copy link
Member

@staabm the target code can be updated with:

if (str_contains($name, "*")) {
    fnmatch()...

else
   $this->isName()

@staabm
Copy link
Contributor Author

staabm commented Sep 11, 2023

rebased.

@samsonasik
Copy link
Member

@staabm please rebase once more :)

Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems all green now :)

@@ -181,6 +186,12 @@ public function isStringName(string $resolvedName, string $desiredName): bool
return $desiredName === $resolvedName;
}

foreach(self::REGEX_WILDCARD_CHARS as $char) {
if (str_contains($desiredName, $char)) {
throw new ShouldNotHappenException('Matching of regular expressions is no longer supported. Use $this->getName() and compare with e.g. str_ends_with() or str_starts_with() instead.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fnmatch should mentioned:

Suggested change
throw new ShouldNotHappenException('Matching of regular expressions is no longer supported. Use $this->getName() and compare with e.g. str_ends_with() or str_starts_with() instead.');
throw new ShouldNotHappenException('Matching of regular expressions is no longer supported. Use $this->getName() and compare with e.g. str_ends_with(), str_starts_with(), or fnmatch() instead.');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fnmatch example https://3v4l.org/MkqgX

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm.., this must be moved in last resort after return strcasecmp($resolvedName, $desiredName) === 0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to exclude fnmatch() on purpose, as it's mostly related to paths, not node names. Also it's pain to use as * works only with specific constant :)

LGTM 👍

@TomasVotruba TomasVotruba merged commit 398b650 into rectorphp:main Sep 11, 2023
38 checks passed
@TomasVotruba
Copy link
Member

Thank you 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants