Skip to content

Commit 7a451f1

Browse files
committed
[Php72] Handle crash on hex backreference on PregReplaceEModifierRector
1 parent 86d83cc commit 7a451f1

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\Fixture;
4+
5+
class CallFunctionVariableNumeric
6+
{
7+
public function run()
8+
{
9+
$result = preg_replace('/%u([a-f0-9]{4,4})/ei', 'utf8_chr(0x$1)', $_REQUEST['content']);
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\Fixture;
18+
19+
class CallFunctionVariableNumeric
20+
{
21+
public function run()
22+
{
23+
$result = preg_replace_callback('/%u([a-f0-9]{4,4})/i', function ($matches) {
24+
return utf8_chr(hexdec($matches[1]));
25+
}, $_REQUEST['content']);
26+
}
27+
}
28+
29+
?>

0 commit comments

Comments
 (0)