| alcaeus | Yes | 2020-07-17 11:10 |
| asgrim | Yes | 2020-07-15 13:30 |
| ashnazg | Yes | 2020-07-15 18:23 |
| beberlei | Yes | 2020-07-15 13:54 |
| brandon | Yes | 2020-07-15 13:40 |
| brzuchal | Yes | 2020-07-15 14:31 |
| bwoebi | Yes | 2020-07-15 14:01 |
| carusogabriel | Yes | 2020-07-15 14:15 |
| colinodell | Yes | 2020-07-15 17:19 |
| cpriest | Yes | 2020-07-15 17:47 |
| cschneid | Yes | 2020-07-15 13:55 |
| dams | Yes | 2020-07-17 17:34 |
| daverandom | Yes | 2020-07-20 00:13 |
| derick | Yes | 2020-07-15 13:55 |
| ekin | Yes | 2020-07-19 15:30 |
| galvao | Yes | 2020-07-17 01:29 |
| girgias | Yes | 2020-07-15 14:11 |
| guilhermeblanco | Yes | 2020-07-15 18:19 |
| ilutov | Yes | 2020-07-15 13:42 |
| jasny | Yes | 2020-07-15 14:08 |
| kalle | Yes | 2020-07-15 22:04 |
| kguest | Yes | 2020-07-17 15:54 |
| kocsismate | Yes | 2020-07-15 13:33 |
| lcobucci | Yes | 2020-07-16 17:47 |
| levim | Yes | 2020-07-15 14:09 |
| marandall | Yes | 2020-07-15 14:01 |
| marcio | Yes | 2020-07-18 17:21 |
| mariano | Yes | 2020-07-15 14:38 |
| mauricio | Yes | 2020-07-24 20:26 |
| mcmic | Yes | 2020-07-21 08:12 |
| nicolasgrekas | Yes | 2020-07-17 11:07 |
| nikic | Yes | 2020-07-15 13:38 |
| peehaa | Yes | 2020-07-16 01:20 |
| petk | Yes | 2020-07-15 20:04 |
| pmjones | Yes | 2020-07-29 02:56 |
| pollita | Yes | 2020-07-17 14:39 |
| ramsey | Yes | 2020-07-15 14:18 |
| rdohms | Yes | 2020-07-17 11:28 |
| reywob | Yes | 2020-07-15 14:06 |
| salathe | Yes | 2020-07-15 14:06 |
| sebastian | Yes | 2020-07-17 14:14 |
| sergey | Yes | 2020-07-15 13:36 |
| sirsnyder | Yes | 2020-07-17 12:20 |
| svpernova09 | Yes | 2020-07-22 16:21 |
| tandre | Yes | 2020-07-15 14:02 |
| theodorejb | Yes | 2020-07-15 13:42 |
| trowski | Yes | 2020-07-15 17:50 |
| twosee | Yes | 2020-07-15 18:19 |
| wyrihaximus | Yes | 2020-07-21 12:16 |
Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC
This RFC proposes to allow an optional trailing comma in closure use lists. This is already supported for argument and parameter lists.
Consider this example:
$longArgs_longVars = function (
$longArgument,
$longerArgument,
$muchLongerArgument, // Trailing commas were allowed in parameter lists in PHP 8.0
) use (
$longVar1,
$longerVar2,
$muchLongerVar3
) {
// body
};
$longArgs_longVars(
$longArgumentValue,
$obj->longMethodCall(),
$obj->longPropertyName ?? $longDefault,
);
This closure declaration has too many parameters and closure use variables to place all of them on one line, at least under conventional coding standards. In such cases PSR-12 recommends using the formatting above instead (PSR-12 predates support for trailing commas in parameter lists).
Unfortunately, it is currently not possible to place a trailing comma in the closure use list. This breaks uniformity, and results in larger diffs when a new optional closure use variable is added. Additionally, it is inconsistent with parameter lists and call-sites, which do allow a trailing comma.
At this point, I'm used to always adding a trailing comma to multi-line lists, regardless of what kind of element they contain. We should avoid having this kind of arbitrary restriction.
Allow a single optional trailing comma in closure use lists.
Allow trailing comma in parameter list added support for trailing commas in parameter lists.
Allow a trailing comma in function calls added support for trailing commas in calls.
Trailing Commas In List Syntax was a previous proposal to support optional trailing commas in all list-like structures.
Nothing has substantially changed since those RFCs in technical terms, but I think the aforementioned style for breaking up large lists has become more accepted in the meantime.
None.
Yes/No, requiring 2/3 majority.
Voting starts 2020-07-15 and ends 2020-07-29.
Vote: Allow trailing comma in closure use lists — Yes: 49 · No: 0 (closed)
0.2: Fix implementation link.
https://externals.io/message/110715 “Permitting trailing commas in closure use() declarations”
https://externals.io/message/110804 “[RFC] Allow trailing comma in closure use list”