-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Changes from 5 commits
ec2a21e
c5a423d
ef9a4fd
c465360
f8cb85c
7855361
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\Fixture; | ||
|
||
class SkipNoModifier | ||
{ | ||
public function run() | ||
{ | ||
echo preg_replace('([[:upper:]]+)', '_$0', 'FOO'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I add more brackets to handle that 7855361 |
||
return null; | ||
} | ||
|
||
$patternWithoutE = $this->createPatternWithoutE($pattern, $delimiter, $modifiers); | ||
return new String_($patternWithoutE); | ||
} | ||
|
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
:which seems needs extra check with
e
modifier which the change must only remove thee
, to be: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.