|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-11 20:05 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 00:00:01 2025 UTC |
Description: ------------ It is not possible to modify an element of an array returned by ArrayAccess::offsetGet(). Also the error message suggests that offsetGet() should return a reference but it is not possible due to the offsetGet() original declaration. Reproduce code: --------------- <? class obj_array implements ArrayAccess { private $array; public function __construct ($array) { $this->array = $array; } public function offsetExists ($index) { return (array_key_exists ($index, $this->array)); } public function offsetGet ($index) { return ($this->array [$index]); } public function offsetSet ($index, $value) { $this->array [$index] = $value; } public function offsetUnset ($index) { unset ($this->array [$index]); } } $obj = new obj_array (array ("index_1" => array ("index_2" => 123))); $obj ["index_1"]["index_2"] = 456; ?> Expected result: ---------------- Nothing should be displayed when the code is run. Actual result: -------------- Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /archive/try.php on line 33