Permitting trailing commas in closure use() declarations
| From: | tyson andre | Date: | Wed, 24 Jun 2020 15:22:51 +0000 |
| Subject: | Permitting trailing commas in closure use() declarations | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-110715@lists.php.net to get a copy of this message | ||
Hi internals,
https://wiki.php.net/rfc/trailing_comma_in_parameter_list
mentioned
> https://wiki.php.net/rfc/list-syntax-trailing-commas 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 parameter lists has become more accepted in the
> meantime, and features like Constructor Property Promotion are going to increase its use further.
So I'm wondering if anyone's interested in revisiting this:
- It'd be easy to forget that function parameters support trailing commas, but not closure
uses, especially if you're new to the language.
- Supporting trailing commas in multi-line declarations would make version control history easier
- if you had a closure for which
fn wouldn't work (a list of values *and
references* to use, or a list of statements),
it'd be convenient to split it up across multiple lines
e.g.
```
$incrementing_id = 0;
return \array_map(static function (array $map) use (
$function,
$some_data_structure,
$some_flag,
&$incrementing_id,
): ReturnType {
```