Skip to content

Blink: tokenize complex interpolation; ratchet mautic 0.07% and laravel 7.25% - #146

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-blink-lexer-interp
Oct 5, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
tv-blink-lexer-interp

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Teaches blink's lexer to tokenize complex {$...} interpolation, clearing the last reflow-able mautic diff, and ratchets both parity gates.

Lexer: complex interpolation

blink folded every double-quoted string into one atomic token, so it could not reflow an array embedded in an interpolated string. lexInterpolatedString now splits a double-quoted string that contains a complex {$...} interpolation into: a literal chunk ending at {, the inner expression lexed as real tokens, a chunk starting at }, repeated, then the closing chunk. The quote, braces, and all literal text stay in the emitted string chunks, so Render stays byte-exact. Simple $var, ${...}, single-quoted strings and heredocs are untouched. Nested, multiple, and escaped interpolations are handled via brace-depth tracking. One consumer (ExplicitStringVariable) was updated to treat a }-leading continuation chunk as interpolation body.

Array fixers can now see the [...] inside "...{$this->translator->trans('...', [ ... ])}..." and reflow it - fixing SummarizeCommand.

Round-trip proven byte-identical across 4737 mautic files, 17 rector-src files, and 9 hand-written edge cases (nested dynamic access, multiple interps, embedded arrays, escapes, embedded quotes, ${simple}).

Gates

  • mautic: 0.1% -> 0.07% (actual 0.066%, 3 of 4527). The remaining 3 are upstream php-cs-fixer/Symplify bugs that can only be matched by bug-for-bug emulation that is not provably rector-gate-safe (two .html.php inline-HTML ArrayIndentation artifacts; FieldsTypeTrait's TokenSkipper::skipBlocksReversed not skipping closure/destructuring blocks).
  • laravel: 7.3% -> 7.25% (actual 7.199%, 219 of 3042). Small step - laravel parity needs a dedicated campaign to move meaningfully, and laravel/framework drifts daily, so the margin is kept modest to avoid flakiness.

Full blink suite, go vet, golangci-lint green; strict rector-src 1:1 gate stays 0-diff; zero mautic regressions.

Split a double-quoted string that contains a complex "{$...}" interpolation
into literal chunks (keeping the quote, "{" and "}") with the inner
expression lexed as real tokens, so array fixers can reflow an array embedded
in a string ("...{$x->trans('...', [ ... ])}..."). Render stays byte-exact.
ExplicitStringVariable now also wraps simple variables in the continuation
chunks of such a split string.
@TomasVotruba
TomasVotruba force-pushed the tv-blink-lexer-interp branch from b169a50 to 1d3fbeb Compare October 5, 2026 21:08
@TomasVotruba
TomasVotruba merged commit d7fb2a2 into main Oct 5, 2026
17 of 19 checks passed
@TomasVotruba
TomasVotruba deleted the tv-blink-lexer-interp branch October 5, 2026 21:08
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