-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
[Php55] Handle crash on ([[:upper:]]+) regex on PregReplaceEModifierRector #3037
Conversation
Fixed 🎉 /cc @jtojnar |
The issue seems on |
All checks have passed 🎉 @TomasVotruba it is ready for review. |
@@ -46,6 +46,10 @@ public function resolvePatternExpressionWithoutEIfFound(Expr $expr): Concat|Stri | |||
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.
Won’t this not handle (…)e
now?
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.
that seems require separate PR as the modifer can not only e
:
echo preg_replace('{[[:upper:]]+}se', '_$0', 'FOO');
which seems needs extra check with e
modifier which the change must only remove the e
, to be:
echo preg_replace('{[[:upper:]]+}s', '_$0', 'FOO');
Also possibly other use cases for that.
Feel free to provide a different PR for solution for that if you found a solution first for that.
rules/Php55/RegexMatcher.php
Outdated
@@ -46,6 +46,10 @@ public function resolvePatternExpressionWithoutEIfFound(Expr $expr): Concat|Stri | |||
return null; | |||
} | |||
|
|||
if ($delimiter === '(' && $pattern[strlen($pattern) - 1] === ')') { |
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.
Also, other brackets can be used as delimiters, to avoid having to escape the characters in the expression: https://www.php.net/manual/en/regexp.reference.delimiters.php
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.
I add more brackets to handle that 7855361
All checks have passed 🎉 @TomasVotruba I think it is ready. |
Thank you 👍 |
Given the following code:
It currently cause crash:
It should be skipped instead.
Fixes rectorphp/rector#7573