1--TEST--
2list() with keys and ArrayAccess
3--FILE--
4<?php
5
6$antonymObject = new ArrayObject;
7$antonymObject["good"] = "bad";
8$antonymObject["happy"] = "sad";
9
10list("good" => $good, "happy" => $happy) = $antonymObject;
11var_dump($good, $happy);
12
13echo PHP_EOL;
14
15$stdClassCollection = new SplObjectStorage;
16$foo = new StdClass;
17$stdClassCollection[$foo] = "foo";
18$bar = new StdClass;
19$stdClassCollection[$bar] = "bar";
20
21list($foo => $fooStr, $bar => $barStr) = $stdClassCollection;
22var_dump($fooStr, $barStr);
23
24echo PHP_EOL;
25
26class IndexPrinter implements ArrayAccess
27{
28    public function offsetGet($offset) {
29        echo "GET ";
30        var_dump($offset);
31    }
32    public function offsetSet($offset, $value) {
33    }
34    public function offsetExists($offset) {
35    }
36    public function offsetUnset($offset) {
37    }
38}
39
40$op = new IndexPrinter;
41list(123 => $x) = $op;
42// PHP shouldn't convert this to an integer offset, because it's ArrayAccess
43list("123" => $x) = $op;
44
45?>
46--EXPECT--
47string(3) "bad"
48string(3) "sad"
49
50string(3) "foo"
51string(3) "bar"
52
53GET int(123)
54GET string(3) "123"
55