Skip to content

Allow optional trailing comma in parameter list #5306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
38 changes: 38 additions & 0 deletions Zend/tests/func_sig_trailing_comma.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
Trailing comma in function signatures
--FILE--
<?php

function test(
$there,
$are,
$many,
$params,
) {
echo "Foo\n";
}

class Test {
public function method(
$there,
$are,
$many,
$params,
) {
echo "Foo\n";
}
}

$func = function(
$there,
$are,
$many,
$params,
) {
echo "Foo\n";
};

?>
===DONE===
--EXPECT--
===DONE===
2 changes: 1 addition & 1 deletion Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ alt_if_stmt:
;

parameter_list:
non_empty_parameter_list { $$ = $1; }
non_empty_parameter_list possible_comma { $$ = $1; }
| %empty { $$ = zend_ast_create_list(0, ZEND_AST_PARAM_LIST); }
;

Expand Down