
Rule trailing_comma_in_multiline
ΒΆ
Multi-line arrays, arguments list, parameters list and match
expressions
must have a trailing comma.
ConfigurationΒΆ
after_heredoc
ΒΆ
Whether a trailing comma should also be placed after heredoc end.
Allowed types: bool
Default value: false
elements
ΒΆ
Where to fix multiline trailing comma (PHP >= 8.0 for parameters
and
match
).
Allowed values: a subset of ['arguments', 'arrays', 'match', 'parameters']
Default value: ['arrays']
ExamplesΒΆ
Example #1ΒΆ
Default configuration.
--- Original
+++ New
<?php
array(
1,
- 2
+ 2,
);
Example #2ΒΆ
With configuration: ['after_heredoc' => true]
.
--- Original
+++ New
<?php
$x = [
'foo',
<<<EOD
bar
- EOD
+ EOD,
];
Example #3ΒΆ
With configuration: ['elements' => ['arguments']]
.
--- Original
+++ New
<?php
foo(
1,
- 2
+ 2,
);
Example #4ΒΆ
With configuration: ['elements' => ['parameters']]
.
--- Original
+++ New
<?php
function foo(
$x,
- $y
+ $y,
)
{
}
Rule setsΒΆ
The rule is part of the following rule sets:
@PHP73Migration with config:
['after_heredoc' => true]
@PHP74Migration with config:
['after_heredoc' => true]
@PHP80Migration with config:
['after_heredoc' => true]
@PHP81Migration with config:
['after_heredoc' => true]
@PHP82Migration with config:
['after_heredoc' => true]
@PHP83Migration with config:
['after_heredoc' => true]
Source classΒΆ
PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer