1--TEST-- 2ZE2 ArrayAccess cannot assign by reference 3--FILE-- 4<?php 5 6class ArrayAccessImpl implements ArrayAccess { 7 private $data = array(); 8 9 public function offsetUnset($index): void {} 10 11 public function offsetSet($index, $value): void { 12 $this->data[$index] = $value; 13 } 14 15 public function offsetGet($index): mixed { 16 return $this->data[$index]; 17 } 18 19 public function offsetExists($index): bool { 20 return isset($this->data[$index]); 21 } 22} 23 24$data = new ArrayAccessImpl(); 25$test = 'some data'; 26$data['element'] = NULL; // prevent notice 27$data['element'] = &$test; 28 29?> 30===DONE=== 31--EXPECTF-- 32Notice: Indirect modification of overloaded element of ArrayAccessImpl has no effect in %sarray_access_012.php on line 24 33 34Fatal error: Uncaught Error: Cannot assign by reference to an array dimension of an object in %sarray_access_012.php:24 35Stack trace: 36#0 {main} 37 thrown in %sarray_access_012.php on line 24 38