com php-src: Support optional comma in closure use list: Zend/tests/closure_use_trailing_comma.phpt Zend/zend _language_parser.y

From: Date: Tue, 21 Jul 2020 17:01:27 +0000
Subject: com php-src: Support optional comma in closure use list: Zend/tests/closure_use_trailing_comma.phpt Zend/zend _language_parser.y
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112300@lists.php.net to get a copy of this message
Commit: 4cf8b6f1c9090a75d9012701699f7c363bd7b7a7 Author: Tyson Andre <tysonandre775@hotmail.com> Wed, 1 Jul 2020 13:28:39 -0400 Parents: 69a5c561d05c8074afe53b8d545d6a6205343aac Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4cf8b6f1c9090a75d9012701699f7c363bd7b7a7 Log: 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 Changed paths: A Zend/tests/closure_use_trailing_comma.phpt M Zend/zend_language_parser.y Diff: diff --git a/Zend/tests/closure_use_trailing_comma.phpt b/Zend/tests/closure_use_trailing_comma.phpt new file mode 100644 index 0000000000..7bf6e5ce88 --- /dev/null +++ b/Zend/tests/closure_use_trailing_comma.phpt @@ -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 diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 40938256f2..891624c461 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -1155,7 +1155,7 @@ returns_ref: lexical_vars: %empty { $$ = NULL; } - | T_USE '(' lexical_var_list ')' { $$ = $3; } + | T_USE '(' lexical_var_list possible_comma ')' { $$ = $3; } ; lexical_var_list:

« previous php.cvs (#112300) next »