Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php55] Handle crash on curly parentheses delimiter on PregReplaceEMo…
…difierRector (#3144) * [Php55] Handle curly parentheses delimiter on PregReplaceEModifierRector * Fixed :tada * [ci-review] Rector Rectify * clean up * skip * Real solution * simplify test * [ci-review] Rector Rectify * clean up * rename fixture and update fixture to avoid remove e inside regex * Fixed 🎉 * Final touch: eol * celan up * ensure encapsed parts only 1 for this specific condition * Final touch: PHPStan * final touch: re-assign * add failing fixture e inside regex not as modifier * Fixed 🎉 * Really Final touch: clean up * Final touch: enforce string on get value of Encapsed part * Final touch: future comment for { } handling on Encapsed Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
139c19c
commit 1664739
Showing
5 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...55/Rector/FuncCall/PregReplaceEModifierRector/Fixture/curly_parentheses_delimiter.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\Fixture; | ||
|
||
// https://3v4l.org/fqdPZ#v5.4.45 vs https://3v4l.org/Zm16C#v5.5.38 | ||
function clean_link($a) | ||
{ | ||
return "change"; | ||
} | ||
|
||
function run($str) | ||
{ | ||
$eval_links = '$link = clean_link("$0")'; | ||
|
||
return preg_replace('{test}ei',"$eval_links",$str); | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\Fixture; | ||
|
||
// https://3v4l.org/fqdPZ#v5.4.45 vs https://3v4l.org/Zm16C#v5.5.38 | ||
function clean_link($a) | ||
{ | ||
return "change"; | ||
} | ||
|
||
function run($str) | ||
{ | ||
$eval_links = '$link = clean_link("$0")'; | ||
|
||
return preg_replace_callback('{test}i',function ($matches) use ($eval_links) { | ||
return $link = clean_link($matches[0]); | ||
},$str); | ||
} | ||
|
||
?> |
16 changes: 16 additions & 0 deletions
16
...tor/FuncCall/PregReplaceEModifierRector/Fixture/skip_e_inside_regex_no_e_modifier.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\Fixture; | ||
|
||
function clean_link($a) | ||
{ | ||
return "change"; | ||
} | ||
|
||
function run($str) | ||
{ | ||
$eval_links = '$link = clean_link("$0")'; | ||
|
||
return preg_replace('{test}i',"$eval_links",$str); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters