Skip to content

Commit 4cf8b6f

Browse files
committed
Support optional comma in closure use list
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
1 parent 69a5c56 commit 4cf8b6f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Closure use list can have trailing commas
3+
--FILE--
4+
<?php
5+
6+
$b = 'test';
7+
$fn = function () use (
8+
$b,
9+
&$a,
10+
) {
11+
$a = $b;
12+
};
13+
$fn();
14+
echo "$a\n";
15+
?>
16+
--EXPECT--
17+
test

Zend/zend_language_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ returns_ref:
11551155

11561156
lexical_vars:
11571157
%empty { $$ = NULL; }
1158-
| T_USE '(' lexical_var_list ')' { $$ = $3; }
1158+
| T_USE '(' lexical_var_list possible_comma ')' { $$ = $3; }
11591159
;
11601160

11611161
lexical_var_list:

0 commit comments

Comments
 (0)