1.2.1323. Use Closure Trailing Comma¶
Use a trailing comma in the closure <https://www.php.net/`closure>`_’s use
list.
A trailing comma doesn’t add any argument, not even a void or null one. It is a convenient for VCS to make diff with the previous code, and have them more readable.
This feature was added in PHP 8.0.
<?php
// PHP 8.0 valid syntax
$f = function foo() use ($a, ) { };
// always valid syntax for closure
$f = function foo() use ($a ) { };
?>
See also Trailing Comma In Closure Use List.
1.2.1323.1. Connex PHP features¶
1.2.1323.1.1. Suggestions¶
Add a trailing comma when there are more than one argument in the use expression
1.2.1323.1.2. Specs¶
Short name |
Php/UseTrailingUseComma |
Rulesets |
|
Exakat since |
2.1.6 |
PHP Version |
With PHP 8.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |