Repository navigation
Commit 20d1886
Reproduce php_strip_whitespace() byte for byte in the native symbol scan
The native stripper in front of SymbolFinderInFiles' cleaner removed
comments with a hand scanner and copied everything else through, on the
claim that whitespace does not matter downstream. Both halves were wrong:
- inside {$...} / ${...} interpolation the lexer is in script mode, so a
nested "..." is a separate string; the scanner ended the outer string
at it, lost `class HashInterp` after "{$a["#"]}" and invented a class
inside "{$a["/*"]}";
- zend_strip() collapses whitespace tokens, newlines included, and after
a heredoc's closing label writes the next token verbatim - a comment
too - followed by "\n". The cleaner's // handling skips to the next
newline and its quote pairing is naive, so which symbols survive
depends on exactly those bytes.
Port the lexer rules zend_strip() can observe instead (states and state
stack for strings, interpolation, heredoc/nowdoc, variable offsets and
property lookups, brace nesting; the tokens that keep whitespace or
comments inside - casts, `yield from`; the skipped shebang line) and
mirror zend_strip() on top. The output is byte-identical to
php_strip_whitespace() over the repository and vendor/ and over ~40,000
fuzzed and mutated inputs, with short_open_tag on and off.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Fdg8n3eEi4ZoXa4dA2k4A1 parent 7af8b74 commit 20d1886
3 files changed
Lines changed: 917 additions & 149 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
0 commit comments