--TEST-- bug #70321 (Magic getter breaks reference to array property) --FILE-- bar = new bar(); } public function & __get($key) { $bar = $this->bar; return $bar; } public function & offsetGet($key): mixed { $bar = $this->bar; return $bar; } public function offsetSet($key, $val): void { } public function offsetUnset($key): void { } public function offsetExists($key): bool { } } class bar { public $onBaz = []; } $foo = new foo(); $foo->bar->onBaz[] = function() {}; var_dump($foo->bar->onBaz); $foo = new foo(); $foo["bar"]->onBaz[] = function() {}; var_dump($foo->bar->onBaz); ?> --EXPECTF-- array(1) { [0]=> object(Closure)#%d (3) { ["name"]=> string(%d) "{closure:%s:%d}" ["file"]=> string(%d) "%s" ["line"]=> int(%d) } } array(1) { [0]=> object(Closure)#%d (3) { ["name"]=> string(%d) "{closure:%s:%d}" ["file"]=> string(%d) "%s" ["line"]=> int(%d) } }