Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Support optional comma in closure use list
  • Loading branch information
TysonAndre committed Jul 1, 2020
commit cebbac923c1c88a9f52ae34d97506d55a97f10aa
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 @@ -1132,7 +1132,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