mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Allow trailing comma
This commit is contained in:
parent
f4c8b2cb30
commit
14bfe93ddc
2 changed files with 39 additions and 1 deletions
38
Zend/tests/list_keyed_trailing_comma.phpt
Normal file
38
Zend/tests/list_keyed_trailing_comma.phpt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
--TEST--
|
||||||
|
list() with keys and a trailing comma
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$antonyms = [
|
||||||
|
"good" => "bad",
|
||||||
|
"happy" => "sad",
|
||||||
|
];
|
||||||
|
|
||||||
|
list(
|
||||||
|
"good" => $good,
|
||||||
|
"happy" => $happy
|
||||||
|
) = $antonyms;
|
||||||
|
|
||||||
|
var_dump($good, $happy);
|
||||||
|
|
||||||
|
echo PHP_EOL;
|
||||||
|
|
||||||
|
$antonyms = [
|
||||||
|
"good" => "bad",
|
||||||
|
"happy" => "sad",
|
||||||
|
];
|
||||||
|
|
||||||
|
list(
|
||||||
|
"good" => $good,
|
||||||
|
"happy" => $happy,
|
||||||
|
) = $antonyms;
|
||||||
|
|
||||||
|
var_dump($good, $happy);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(3) "bad"
|
||||||
|
string(3) "sad"
|
||||||
|
|
||||||
|
string(3) "bad"
|
||||||
|
string(3) "sad"
|
|
@ -1174,7 +1174,7 @@ property_name:
|
||||||
assignment_list:
|
assignment_list:
|
||||||
unkeyed_assignment_list
|
unkeyed_assignment_list
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
| keyed_assignment_list
|
| keyed_assignment_list possible_comma
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue