Permitting trailing commas in closure use() declarations

  110715
June 24, 2020 15:22 tysonandre775@hotmail.com (tyson andre)
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 { ```
  110796
July 1, 2020 07:39 nikita.ppv@gmail.com (Nikita Popov)
On Wed, Jun 24, 2020 at 5:23 PM tyson andre <tysonandre775@hotmail.com>
wrote:

> 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 { > ``` >
Sounds reasonable to me. I thought we had already covered all cases that are inside (), but apparently not. I think if there are no objections on list, we can just land this change. Given how positive the outcome of the "trailing comma in parameter lists" RFC was this doesn't seem controversial. Regards, Nikita