Skip to content

Port php-cs-fixer StatementIndentation test cases (WIP) - #132

Merged
TomasVotruba merged 4 commits into
mainfrom
tv-blink-stmt-indent-tests
Oct 4, 2026
Merged

TomasVotruba merged 4 commits into
mainfrom
tv-blink-stmt-indent-tests

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Moves the php-cs-fixer StatementIndentationFixerTest suite into a Go table test, to pin blink's StatementIndentation behavior and scope the gap before any rule change. No rule change in this PR.

All 86 cases from tests/Fixer/Whitespace/StatementIndentationFixerTest.php are ported verbatim (expected, input, and the stick_comment_to_next_continuous_control_statement config where set). blink currently matches 27 of them.

The 59 it does not yet match are gated behind a documented stmtIndentKnownFailures allowlist so the port stays green; a listed case that starts passing fails the test, so the list gets pruned as the rule improves. The single tab-indent case cannot be expressed through blink's test harness (no WhitespacesFixerConfig) and stays a known gap.

Move all 86 cases from php-cs-fixer StatementIndentationFixerTest into a Go
table test. blink matches 27; the 59 it does not yet match are gated behind
a documented known-failures allowlist so the port lands without changing the
rule. A listed case that starts passing fails the test so the list is pruned.
Port php-cs-fixer's StatementIndentationFixer (bracesFixerCompatibility=false):
walk block, block_signature and statement scopes and reindent each line to
four spaces per nesting level, including continuation lines inside multiline
calls and arrays that the previous rule left untouched. Promoted constructor
parameters are not treated as property starts, so their modifiers do not stack
signature scopes.

Passes 83 of 86 ported php-cs-fixer cases; the 3 gated are multiline trait use
(CT::T_USE_TRAIT) and the tab-indent case the harness cannot express. Mautic
parity improves from 53 to 40 differing files with no regression.
…signature

A contextual keyword lexed as a keyword but used as an identifier
("Enum::MODE_ADD", "new Match", "$o->enum") no longer starts a
block_signature scope, which had stacked unpopped scopes and over-indented
the closing "]);" of an array call argument. A following "\" is a
namespace prefix on the operand ("case \Foo::BAR:") and does not count.
@TomasVotruba
TomasVotruba merged commit ffbcd1e into main Oct 4, 2026
18 checks passed
@TomasVotruba
TomasVotruba deleted the tv-blink-stmt-indent-tests branch October 4, 2026 19:43
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