Skip to content

Commit

Permalink
minor: TrailingCommaInMultilineFixer - Add comma to multiline `new st…
Browse files Browse the repository at this point in the history
…atic` (#6380)
  • Loading branch information
dpi authored Aug 13, 2022
1 parent 3b471b4 commit 32cf09e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$prevPrevIndex = $tokens->getPrevMeaningfulToken($prevIndex);

if ($fixArguments
&& $tokens[$prevIndex]->equalsAny([']', [T_CLASS], [T_STRING], [T_VARIABLE]])
&& $tokens[$prevIndex]->equalsAny([']', [T_CLASS], [T_STRING], [T_VARIABLE], [T_STATIC]])
&& !$tokens[$prevPrevIndex]->isGivenKind(T_FUNCTION)
) {
$this->fixBlock($tokens, $index);
Expand Down
11 changes: 11 additions & 0 deletions tests/Fixer/ControlStructure/TrailingCommaInMultilineFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,17 @@ function a()
,
['after_heredoc' => true],
],
[
'<?php $a = new class() {function A() { return new static(
1,
2,
); }};',
'<?php $a = new class() {function A() { return new static(
1,
2
); }};',
['elements' => [TrailingCommaInMultilineFixer::ELEMENTS_ARGUMENTS]],
],
];
}

Expand Down

0 comments on commit 32cf09e

Please sign in to comment.