1--TEST-- 2"Reference Unpacking - Class ArrayAccess No Reference" list() 3--FILE-- 4<?php 5class StorageNoRef implements ArrayAccess { 6 private $s = []; 7 function __construct(array $a) { $this->s = $a; } 8 function offsetSet ($k, $v): void { $this->s[$k] = $v; } 9 function offsetGet ($k): mixed { return $this->s[$k]; } 10 function offsetExists ($k): bool { return isset($this->s[$k]); } 11 function offsetUnset ($k): void { unset($this->s[$k]); } 12} 13 14$a = new StorageNoRef([1, 2]); 15list(&$one, $two) = $a; 16var_dump($a); 17 18$a = new StorageNoRef([1, 2]); 19list(,,list($var)) = $a; 20var_dump($a); 21 22$a = new StorageNoRef(['one' => 1, 'two' => 2]); 23['one' => &$one, 'two' => $two] = $a; 24var_dump($a); 25?> 26--EXPECTF-- 27Notice: Indirect modification of overloaded element of %s has no effect in %s on line %d 28object(StorageNoRef)#1 (1) { 29 ["s":"StorageNoRef":private]=> 30 array(2) { 31 [0]=> 32 int(1) 33 [1]=> 34 int(2) 35 } 36} 37 38Warning: Undefined array key 2 in %s on line %d 39object(StorageNoRef)#2 (1) { 40 ["s":"StorageNoRef":private]=> 41 array(2) { 42 [0]=> 43 int(1) 44 [1]=> 45 int(2) 46 } 47} 48 49Notice: Indirect modification of overloaded element of %s has no effect in %s on line %d 50object(StorageNoRef)#1 (1) { 51 ["s":"StorageNoRef":private]=> 52 array(2) { 53 ["one"]=> 54 int(1) 55 ["two"]=> 56 int(2) 57 } 58} 59