Skip to content

Add named-argument colon spacing to blink - #243

Merged
TomasVotruba merged 1 commit into
mainfrom
worktree-agent-a78cdc57c10977297
Oct 30, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
worktree-agent-a78cdc57c10977297

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Problem

blink left foo(name:$x) unchanged, while PHP ECS normalizes a named-argument colon to a single space after it (foo(name: $x)). This showed up on the laravel corpus:

  • Http::response('...', status:500) -> status: 500
  • ->andReturn(m:mock(X::class)) -> m: mock(X::class)

Finding

The task assumed MethodArgumentSpaceFixer owns this. It does not - the vendored MethodArgumentSpaceFixer only handles commas. The real owner is SingleSpaceAroundConstructFixer via its named_argument virtual construct (CT::T_NAMED_ARGUMENT_COLON), confirmed by running ECS on an isolated snippet (only SingleSpaceAroundConstructFixer is attributed) and by NamedArgumentTransformer. ECS keeps the space before the colon and only ensures a single space after - matching that here.

Change

SingleSpaceAroundConstruct now handles the named_argument construct. A colon is a named-argument colon when its previous meaningful token is a name and the one before that is ( or , - exactly php-cs-fixer's NamedArgumentTransformer rule, which excludes ::, ternary ?:, return-type ): Type, goto labels and colons inside strings/comments. The space after is collapsed to one; the space before is left as-is.

Validation

  • New unit tests in constructs_config_test.go (space after, second argument, multiple-space collapse, keep-space-before, and left-untouched for ::, ternary, return-type colon, string colon, and off-by-default).
  • Corpus diff vs ECS: ExceptionHandlerTest.php is now identical; ContextualAttributeBindingTest.php named-arg lines now match (its two unrelated divergences - a new X() -> new X and an attribute-array expansion - remain, as expected).
  • gofmt, go vet, go test -race ./..., golangci-lint all pass.

@TomasVotruba
TomasVotruba merged commit 8724b3b into main Oct 30, 2026
21 checks passed
@TomasVotruba
TomasVotruba deleted the worktree-agent-a78cdc57c10977297 branch October 30, 2026 16:48
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