Skip to content

Commit

Permalink
Support optional comma in closure use list
Browse files Browse the repository at this point in the history
RFC: https://wiki.php.net/rfc/trailing_comma_in_closure_use_list
Discussion: https://externals.io/message/110715

The release manager has agreed to allow merging of RFCs that have near-unanimous
votes. If an RFC ends up not achieving the required 2/3 majority at the time the
announced voting period closes, this implementation commit will be reverted
in time for the feature freeze.

Closes GH-5793
  • Loading branch information
TysonAndre committed Jul 21, 2020
1 parent 69a5c56 commit 4cf8b6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Zend/tests/closure_use_trailing_comma.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Closure use list can have trailing commas
--FILE--
<?php

$b = 'test';
$fn = function () use (
$b,
&$a,
) {
$a = $b;
};
$fn();
echo "$a\n";
?>
--EXPECT--
test
2 changes: 1 addition & 1 deletion Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ returns_ref:

lexical_vars:
%empty { $$ = NULL; }
| T_USE '(' lexical_var_list ')' { $$ = $3; }
| T_USE '(' lexical_var_list possible_comma ')' { $$ = $3; }
;

lexical_var_list:
Expand Down

0 comments on commit 4cf8b6f

Please sign in to comment.