Skip to content

Add trailing comma via suffixLast when addCommaAfterEachArgument is false#11

Merged
ruudk merged 1 commit intomainfrom
ruudk/trailing-comma-suffix-last
Mar 15, 2026
Merged

Add trailing comma via suffixLast when addCommaAfterEachArgument is false#11
ruudk merged 1 commit intomainfrom
ruudk/trailing-comma-suffix-last

Conversation

@ruudk
Copy link
Copy Markdown
Owner

@ruudk ruudk commented Mar 15, 2026

Summary

When addCommaAfterEachArgument is false in dumpCall, no commas were added at all. PHP CS Fixer expects a trailing comma on the last argument in multiline function calls.

This changes the false behavior to use suffixLast(',', $args) instead of just $args, adding a comma only to the last argument line. This is useful for multi-line constructs like match expressions used as function arguments:

// Before (no trailing comma after })
Type::nonNull(
    match (true) {
        $a => $this->getType('Foo'),
        default => $this->getType('Bar'),
    }
)

// After (trailing comma on last argument only)
Type::nonNull(
    match (true) {
        $a => $this->getType('Foo'),
        default => $this->getType('Bar'),
    },
)

Both the static call path and object call path are updated.

Test plan

  • Added tests for both static and iterable object call paths
  • Full test suite passes (167 tests, 308 assertions)

…alse

When addCommaAfterEachArgument is false, dumpCall previously added no
commas at all. PHP CS Fixer expects a trailing comma on the last
argument in multiline function calls. Use suffixLast to add a comma
only to the last argument line instead of every line.
@ruudk ruudk merged commit 5fd2375 into main Mar 15, 2026
2 checks passed
@ruudk ruudk deleted the ruudk/trailing-comma-suffix-last branch March 15, 2026 09:28
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