Skip to content

[Php70] Treat unescaped { as literal in EregToPcreTransformer - #8964

Merged
samsonasik merged 1 commit into
rectorphp:mainfrom
hmennen90:fix-ereg-literal-brace
Nov 17, 2026
Merged

samsonasik merged 1 commit into
rectorphp:mainfrom
hmennen90:fix-ereg-literal-brace

Conversation

@hmennen90

Copy link
Copy Markdown
Contributor

Fixes a crash in EregToPregMatchRector.

ereg_replace('{[0-9]*}', '', $s) threw InvalidEregException: unescaped metacharacter "{", which is not caught, so Rector aborted the whole file ("Could not process ... due to System error").

A { that is not followed by a digit is a literal in POSIX ERE (the original ereg implementation treats it that way). The transformer now always emits \{ for it. Before, only { followed by a digit was handled.

Added a fixture: {[0-9]*} becomes #\{[0-9]*\}#mi.

A { that is not followed by a digit, e.g. ereg_replace('{[0-9]*}', ...), threw InvalidEregException and aborted the whole file. Like in the original ereg implementation it is now a literal brace.
@samsonasik
samsonasik merged commit e3a0b4f into rectorphp:main Nov 17, 2026
51 checks passed
@samsonasik

Copy link
Copy Markdown
Member

Thank you @hmennen90

@hmennen90
hmennen90 deleted the fix-ereg-literal-brace branch November 17, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants