Skip to content

Commit

Permalink
Symfony: don't suppress newlines in parameter lists with trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrms committed Jan 8, 2025
1 parent 262de6c commit e17d24d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Rules.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Contract/ListRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface ListRule extends Rule
* Each token in `$items` is the first code token after `$parent` or a
* delimiter.
*
* `$lastChild` is the last code token in the list. It may be a delimiter.
*
* This method is not called for empty lists.
*/
public function processList(Token $parent, TokenCollection $items, Token $lastChild): void;
Expand Down
9 changes: 6 additions & 3 deletions src/Rule/Preset/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ public function processTokens(array $tokens): void
/**
* Apply the rule to a token and the list of items associated with it
*
* Newlines are suppressed between parameters in function declarations that
* have no promoted constructor parameters.
* Newlines are suppressed in parameter lists with no promoted constructor
* parameters and no trailing comma.
*/
public function processList(Token $parent, TokenCollection $items, Token $lastChild): void
{
if (!$parent->isParameterList()) {
if (
!$parent->isParameterList()
|| $lastChild->id === \T_COMMA
) {
return;
}

Expand Down

0 comments on commit e17d24d

Please sign in to comment.