1--TEST--
2Array unpacking with string keys
3--FILE--
4<?php
5
6// Works with both arrays and Traversables.
7$array = [1, 2, "foo" => 3, 4];
8var_dump([...$array]);
9
10$iterator = new ArrayIterator([1, 2, "foo" => 3, 4]);
11var_dump([...$iterator]);
12
13// Test overwriting behavior.
14$array1 = ["foo" => 1];
15$array2 = ["foo" => 2];
16var_dump(["foo" => 0, ...$array1, ...$array2]);
17var_dump(["foo" => 0, ...$array1, ...$array2, "foo" => 3]);
18
19// Test numeric string key from iterator.
20function gen() {
21    yield "42" => 42;
22}
23var_dump([...gen()]);
24
25// Same as previous, but with refcounted string.
26function gen2() {
27    $foo = "2";
28    yield "4" . $foo => 42;
29}
30var_dump([...gen2()]);
31
32?>
33--EXPECT--
34array(4) {
35  [0]=>
36  int(1)
37  [1]=>
38  int(2)
39  ["foo"]=>
40  int(3)
41  [2]=>
42  int(4)
43}
44array(4) {
45  [0]=>
46  int(1)
47  [1]=>
48  int(2)
49  ["foo"]=>
50  int(3)
51  [2]=>
52  int(4)
53}
54array(1) {
55  ["foo"]=>
56  int(2)
57}
58array(1) {
59  ["foo"]=>
60  int(3)
61}
62array(1) {
63  [0]=>
64  int(42)
65}
66array(1) {
67  [0]=>
68  int(42)
69}
70