System error: "Syntax error, unexpected T_NS_SEPARATOR:1"
Hello,
I have got this error message (bin/php is a docker run on a php container, this is my firts experience with Rector. I joined the asked report in this message ) :
bin/php vendor/bin/rector process --clear-cache src/Infrastructure/Web/site/mod_turbolead/classes/openid/Auth/Yadis/ParseHTML.php 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[ERROR] Could not process "src/Infrastructure/Web/site/mod_turbolead/classes/openid/Auth/Yadis/ParseHTML.php" file, due to: "System error: "Syntax error, unexpected T_NS_SEPARATOR:1" Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 269
Sincerly, Frédéric report.txt
Hi,
we'll need exact reproducer from your code. It will be most likely single line, an invalid syntax. You can make one here: https://getrector.org/demo
https://getrector.org/demo/07418a2b-028f-4232-9068-d26c0eb742f5
Thanks. Could you narrow the input file to ~10 lines that cause the issue? Then we can identify the broken spot.
I updated the demo link.
(error come frome here:
$str = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $str);
'chr(\1)' exactly )
Thanks! Could you share a new link to the code? The link is unique per code input, and the link above still contains the old code.
it seems due to PregReplaceEModifierRector, ref https://getrector.org/demo/64cc5d5c-8980-4521-b38e-15c5556bb991
Thanks! Could you share a new link to the code? The link is unique per code input, and the link above still contains the old code.
For sure. Here it is : https://getrector.org/demo/f361369c-058a-42df-b892-deb48f62a16e
That's seems due to no quote in chr(\1):
-chr(\\1)
+chr('\\1')
The following code will be transformed correctly:
$str = preg_replace('~&#([0-9]+);~e', "chr('\\1')", $str);
ref https://getrector.org/demo/73def251-e46e-4a39-b981-8c760d6aaafb
Thank you. I don't know if we can close this issue because it has been solve for my case but I don't know if Rector could embed its correction.
I've merged the fix from https://github.com/rectorphp/rector-src/pull/2771
Thank you @samsonasik for the fix and @frederic100 for the test fixture :+1: