Skip to content

fix: new line in heredoc#1193

Open
jorgsowa wants to merge 1 commit intomainfrom
fix/new-line-heredoc
Open

fix: new line in heredoc#1193
jorgsowa wants to merge 1 commit intomainfrom
fix/new-line-heredoc

Conversation

@jorgsowa
Copy link
Collaborator

Bugs fixed:

  • Escape sequences were ignored in encapsed string parts - in "hello $name\n", the \n after the variable was stored as the literal two characters \ and n instead of a newline. The value field now correctly reflects the runtime value.
  • Trailing newlines were stripped from non-heredoc strings - a cleanup meant only for heredocs (where the final newline before the closing marker is excluded by the PHP spec) was applied to all encapsed strings, silently dropping legitimate trailing newlines from double-quoted and shell strings.
  • Heredoc indentation stripping and escape resolution were applied in wrong order - for heredocs, escape sequences were resolved before indentation was stripped, causing \n escape sequences to be expanded into real newlines
    prematurely, which broke the indentation check and produced incorrect values (e.g. <<<STR\n \na\n STR would raise a false indentation error).
  • " unescaping in double-quoted strings was missing the g flag, so only the first escaped double quote in a string was unescaped.

Fixes: #1131

@jorgsowa jorgsowa force-pushed the fix/new-line-heredoc branch from 48283de to 7504637 Compare March 13, 2026 00:13
@jorgsowa jorgsowa marked this pull request as ready for review March 13, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant