1--TEST--
2"Reference Unpacking - Class ArrayAccess With Reference" list()
3--FILE--
4<?php
5
6class StorageRef implements ArrayAccess {
7    private $s = [];
8    function __construct(array $a) { $this->s = $a; }
9    function offsetSet ($k, $v) { $this->s[$k] = $v; }
10    function &offsetGet ($k) { return $this->s[$k]; }
11    function offsetExists ($k) { return isset($this->s[$k]); }
12    function offsetUnset ($k) { unset($this->s[$k]); }
13}
14
15$a = new StorageRef([1, 2]);
16list(&$one, $two) = $a;
17var_dump($a);
18
19$a = new StorageRef([1, 2]);
20list(,,list($var)) = $a;
21var_dump($a);
22
23$a = new StorageRef([1, 2]);
24list(,,list(&$var)) = $a;
25var_dump($a);
26
27$a = new StorageRef(['one' => 1, 'two' => 2]);
28['one' => &$one, 'two' => $two] = $a;
29var_dump($a);
30
31?>
32--EXPECT--
33object(StorageRef)#1 (1) {
34  ["s":"StorageRef":private]=>
35  array(2) {
36    [0]=>
37    &int(1)
38    [1]=>
39    int(2)
40  }
41}
42object(StorageRef)#2 (1) {
43  ["s":"StorageRef":private]=>
44  array(3) {
45    [0]=>
46    int(1)
47    [1]=>
48    int(2)
49    [2]=>
50    NULL
51  }
52}
53object(StorageRef)#1 (1) {
54  ["s":"StorageRef":private]=>
55  array(3) {
56    [0]=>
57    int(1)
58    [1]=>
59    int(2)
60    [2]=>
61    array(1) {
62      [0]=>
63      &NULL
64    }
65  }
66}
67object(StorageRef)#2 (1) {
68  ["s":"StorageRef":private]=>
69  array(2) {
70    ["one"]=>
71    &int(1)
72    ["two"]=>
73    int(2)
74  }
75}
76