
trailing_comma_in_multiline
¶Multi-line arrays, arguments list, parameters list and match
expressions
must have a trailing comma.
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']
With configuration: ['after_heredoc' => true]
.
--- Original
+++ New
<?php
$x = [
'foo',
<<<EOD
bar
- EOD
+ EOD,
];
With configuration: ['elements' => ['arguments']]
.
--- Original
+++ New
<?php
foo(
1,
- 2
+ 2,
);
With configuration: ['elements' => ['parameters']]
.
--- Original
+++ New
<?php
function foo(
$x,
- $y
+ $y,
)
{
}
The rule is part of the following rule sets:
Using the @PHP73Migration rule set will enable the trailing_comma_in_multiline
rule with the config below:
['after_heredoc' => true]
Using the @PHP74Migration rule set will enable the trailing_comma_in_multiline
rule with the config below:
['after_heredoc' => true]
Using the @PHP80Migration rule set will enable the trailing_comma_in_multiline
rule with the config below:
['after_heredoc' => true]
Using the @PHP81Migration rule set will enable the trailing_comma_in_multiline
rule with the config below:
['after_heredoc' => true]
Using the @PHP82Migration rule set will enable the trailing_comma_in_multiline
rule with the config below:
['after_heredoc' => true]
Using the @PhpCsFixer rule set will enable the trailing_comma_in_multiline
rule with the default config.
Using the @Symfony rule set will enable the trailing_comma_in_multiline
rule with the default config.