#34816 [Opn->Asn]: Inconsitent behavior in ArrayObject for multi-dimensional data
| From: | derick@php.net | Date: | Mon, 10 Oct 2005 17:51:37 +0000 |
| Subject: | #34816 [Opn->Asn]: Inconsitent behavior in ArrayObject for multi-dimensional data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86358@lists.php.net to get a copy of this message | ||
ID: 34816
Updated by: derick@php.net
Reported By: adove at booyahnetworks dot com
-Status: Open
+Status: Assigned
Bug Type: SPL related
Operating System: WinXP
PHP Version: 5.1.0RC1
-Assigned To:
+Assigned To: helly
New Comment:
marcus, this is your baby :)
Previous Comments:
------------------------------------------------------------------------
[2005-10-10 19:42:23] adove at booyahnetworks dot com
Description:
------------
If you create an ArrayObject with mutli-dimensional array data, you can
access unique element paths fine but you can not change/add any
multi-dimensional paths due to the dreaded "Fatal error: Objects used
as arrays in post/pre increment/decrement must return values by
reference" error. Note this happens in BOTH 5.0.5 AND 5.1.0RC1.
IMHO, either the documentation for ArrayObject should clearly indicate
that it supports uni-dimenisional data get/set and ONLY get for
multi-dimensional. OR, the object walk the passed data and turn all
arrays into ArrayObject instances?
Reproduce code:
---------------
$a = array(
"test" => array(
"one" => "dunno",
"two" => array(
"peekabo" => "do you see me?",
"anyone" => array("there")
)
)
);
$oArray = new ArrayObject($a);
var_dump($oArray);
echo "\n\\test\\one == " . $oArray["test"]["one"] . "\n\n";
// NEITHER of the two below will work!
$oArray["test"]["one"] = "Yes I do!";
$oArray["test"]["yes"] = array(
"hello" => "Goodbye!"
);
var_dump($oArray);
Expected result:
----------------
object(ArrayObject)#1 (1) {
["test"]=>
array(2) {
["one"]=>
string(5) "dunno"
["two"]=>
array(2) {
["peekabo"]=>
string(14) "do you see me?"
["anyone"]=>
array(1) {
[0]=>
string(5) "there"
}
}
}
}
\test\one == dunno
object(ArrayObject)#1 (1) {
["test"]=>
array(2) {
["one"]=>
string(5) "Yes I do!"
["two"]=>
array(2) {
["peekabo"]=>
string(14) "do you see me?"
["anyone"]=>
array(1) {
[0]=>
string(5) "there"
}
}
["yes"]=>
array(1) {
["hello"]=>
string(8) "Goodbye!"
}
}
}
Actual result:
--------------
object(ArrayObject)#1 (1) {
["test"]=>
array(2) {
["one"]=>
string(5) "dunno"
["two"]=>
array(2) {
["peekabo"]=>
string(14) "do you see me?"
["anyone"]=>
array(1) {
[0]=>
string(5) "there"
}
}
}
}
\test\one == dunno
Fatal error: Objects used as arrays in post/pre increment/decrement
must return values by reference in array_obje_test.php on line 16
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34816&edit=1