mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Allow optional trailing comma in parameter list
RFC: https://wiki.php.net/rfc/trailing_comma_in_parameter_list Closes GH-5306.
This commit is contained in:
parent
5eb4ab07f2
commit
f545ee2c6c
3 changed files with 49 additions and 1 deletions
|
@ -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
|
||||
|
|
46
Zend/tests/func_sig_trailing_comma.phpt
Normal file
46
Zend/tests/func_sig_trailing_comma.phpt
Normal file
|
@ -0,0 +1,46 @@
|
|||
--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";
|
||||
};
|
||||
|
||||
$func = fn(
|
||||
$there,
|
||||
$shouldnt,
|
||||
$be,
|
||||
$many,
|
||||
$params,
|
||||
) => print "Foo\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
===DONE===
|
|
@ -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); }
|
||||
;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue