rfc:trailing_comma_in_closure_use_list

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:trailing_comma_in_closure_use_list [2020/07/01 17:22] – created tandrerfc:trailing_comma_in_closure_use_list [2020/07/29 18:33] (current) tandre
Line 1: Line 1:
-====== PHP RFC: Allow trailing comma in closure use list ======+====== PHP RFC: Allow trailing comma in closure use lists ====== 
 +  * Version: 0.2
   * Date: 2020-07-01   * Date: 2020-07-01
   * Author: Tyson Andre <tandre@php.net>   * Author: Tyson Andre <tandre@php.net>
-  * Status: Draft+  * Status: Implemented
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
-  * Implementation: https://github.com/php/php-src/pull/5306+  * Implementation: https://github.com/php/php-src/pull/5793
  
 ===== Introduction ===== ===== Introduction =====
Line 16: Line 17:
     $longArgument,     $longArgument,
     $longerArgument,     $longerArgument,
-    $muchLongerArgument,+    $muchLongerArgument,  // Trailing commas were allowed in parameter lists in PHP 8.0
 ) use ( ) use (
     $longVar1,     $longVar1,
Line 24: Line 25:
    // body    // body
 }; };
 +$longArgs_longVars(
 +    $longArgumentValue,
 +    $obj->longMethodCall(),
 +    $obj->longPropertyName ?? $longDefault,
 +);
 </PHP> </PHP>
  
-This constructor 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 [[https://www.php-fig.org/psr/psr-12/#7-closures|PSR-12]] recommends to use the formatting above instead (PSR-12 predates support for trailing commas in parameter lists).+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 [[https://www.php-fig.org/psr/psr-12/#7-closures|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. 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.
Line 52: Line 58:
 ===== Vote ===== ===== Vote =====
  
-Yes/No, requiring 2/3 majority+Yes/No, requiring 2/3 majority.
  
 +Voting starts 2020-07-15 and ends 2020-07-29.
  
 +<doodle title="Allow trailing comma in closure use lists" auth="tandre" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
 +===== Changelog =====
 +
 +0.2: Fix implementation link.
 +
 +===== Discussion ======
 +
 +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"
rfc/trailing_comma_in_closure_use_list.1593624160.txt.gz · Last modified: 2020/07/01 17:22 by tandre