1.2.1407. Useless Trailing Comma¶
Trailing comma is the last comma in a call or function definition. It is left with an empty slot aftewards, so as to reduce the diff when adding or removing an element.
Trailing commas appear in array definition, method calls, method definitions, including use expression for closures and use call.
Trailing comma with only one element are reported as useless. Then, for multiple elements, the elements should be on separate lines.
This is a coding convention.
<?php
$good = array(1,
2,
3,
4,
);
// The trailing comma is just useless.
$bad = array( 1, 2, 3, 4, );
?>
1.2.1407.1. Connex PHP features¶
1.2.1407.1.1. Suggestions¶
Remove the trailing comma
Put the trailing comma on a new line
1.2.1407.1.2. Specs¶
Short name |
Structures/UselessTrailingComma |
Rulesets |
|
Exakat since |
2.6.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |