Skip to content

Blink parity: closure-body expansion, operator linebreak, trim-array comma; gate to 0.15% - #141

Merged
TomasVotruba merged 4 commits into
mainfrom
tv-blink-parity-r8
Oct 5, 2026
Merged

TomasVotruba merged 4 commits into
mainfrom
tv-blink-parity-r8

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Three endgame parity fixes. Measured drop: 8 to 5 differing files of 4527 (0.11%).

1. OperatorLinebreak: object operators and ::

OperatorLinebreakFixer's token set includes ->, ?->, and ::, which blink excluded - so a wrapped method chain kept the operator trailing instead of moving it to the line start. Added them to blink's operator set. (SlotNameTypeValidator.php)

2. BracesPosition: expand single-line closure bodies

With allow_single_line_anonymous_functions: false (the mautic config), ECS expands a single-line closure body onto multiple lines:

array_walk($matchArgs, function (string &$element): void {
    $element = trim($element, '"');
});

blink accepted the option but ignored it. Implemented the expansion, guarded against empty bodies, already-multiline bodies, and a comment on the brace line. (CommonRepositoryTest.php)

3. TrimArraySpaces: keep space after a trailing comma

php-cs-fixer keeps the space before ] when the preceding token is a , (1, ]); blink trimmed it. Added the trailing-comma guard. (CampaignControllerFunctionalTest.php)

Gate

MAX_DIFF_PERCENT lowered 0.2 to 0.15; actual is 0.11% (5 of 4527).

Each fix carries a focused unit test. Full blink suite, go vet, golangci-lint green; strict rector-src 1:1 gate stays 0-diff.

Remaining 5 (not in this PR)

Lexer/scope-bound: array inside an interpolated string (SummarizeCommand - interpolated strings are one token), fn&() by-ref spacing (context-dependent, low yield), list-destructuring expansion (FieldsTypeTrait - conflicts with an existing destructuring guard), and two .html.php templates (array indentation inside a deeply-indented inline-HTML PHP block).

php-cs-fixer's OperatorLinebreak also moves "->", "?->" and "::" (object
operator kinds + T_PAAMAYIM_NEKUDOTAYIM) to the beginning of the next line when
they end a line in a multiline expression. blink excluded them, leaving a
wrapped method chain with "->" trailing; now they are moved like ECS.
Honor BracesPosition's allow_single_line_anonymous_functions=false: a
single-line anonymous function body is put on its own lines, matching
php-cs-fixer. An empty body, one already on its own line, or one sharing the
brace line with a comment is left alone.
TrimArraySpaces removed the single-line space before "]" even after a
trailing comma ("1, ]" -> "1,]"); php-cs-fixer keeps it when the preceding
token is a comma. Guard the trailing-space trim against a preceding comma.
@TomasVotruba
TomasVotruba merged commit de8b2ac into main Oct 5, 2026
18 checks passed
@TomasVotruba
TomasVotruba deleted the tv-blink-parity-r8 branch October 5, 2026 12:12
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