From: Nikita Popov Date: Thu, 26 Mar 2020 15:39:08 +0000 (+0100) Subject: Allow optional trailing comma in parameter list X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f545ee2c6cc63bae79cc5618f2019e3d9bc2dfa5;p=php Allow optional trailing comma in parameter list RFC: https://wiki.php.net/rfc/trailing_comma_in_parameter_list Closes GH-5306. --- diff --git a/UPGRADING b/UPGRADING index c4eca6daaa..40a78fcad5 100644 --- a/UPGRADING +++ b/UPGRADING @@ -462,6 +462,8 @@ PHP 8.0 UPGRADE NOTES RFC: https://wiki.php.net/rfc/abstract_trait_method_validation . `throw` can now be used as an expression. RFC: https://wiki.php.net/rfc/throw_expression + . An optional trailing comma is now allowed in parameter lists. + RFC: https://wiki.php.net/rfc/trailing_comma_in_parameter_list - Date: . Added DateTime::createFromInterface() and diff --git a/Zend/tests/func_sig_trailing_comma.phpt b/Zend/tests/func_sig_trailing_comma.phpt new file mode 100644 index 0000000000..8153edbb05 --- /dev/null +++ b/Zend/tests/func_sig_trailing_comma.phpt @@ -0,0 +1,46 @@ +--TEST-- +Trailing comma in function signatures +--FILE-- + print "Foo\n"; + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index c75c1e6993..78b6e758ba 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -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); } ;