ID: 28831 User updated by: nospam0 at malkusch dot de Reported By: nospam0 at malkusch dot de Status: Bogus Bug Type: Arrays related Operating System: Linux PHP Version: 5CVS-2004-06-18 (dev) New Comment:
> Try this code: > <?php > > $array = new ArrayObject(); > $subArray = new ArrayObject(); > $array->append($subArray); > > $subArray->append(\'item\'); > var_dump($array); > > $x=$array->offsetGet(0); > $x->append(\'item2\'); > var_dump($array); > var_dump($x); > > ?> I don't think, that the output is expected: object(ArrayObject)#1 (1) { [0]=> object(ArrayObject)#2 (1) { [0]=> string(4) "item" } } object(ArrayObject)#1 (1) { [0]=> NULL } object(ArrayObject)#2 (2) { [0]=> string(4) "item" [1]=> string(5) "item2" } Why is there a NULL in the second var_dump? If offsetGet() would not return a reference I would at least expect, that my ArrayObject won't loose its entry. It seems that offsetGet() does the work of offsetUnset(). Previous Comments: ------------------------------------------------------------------------ [2004-06-18 20:55:21] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Unfortunatley internal functions cannot return a reference....... Try this code: <?php $array = new ArrayObject(); $subArray = new ArrayObject(); $array->append($subArray); $subArray->append(\'item\'); var_dump($array); $x=$array->offsetGet(0); $x->append(\'item2\'); var_dump($array); var_dump($x); ?> ------------------------------------------------------------------------ [2004-06-18 16:19:13] nospam0 at malkusch dot de Description: ------------ If I save an ArrayObject in an ArrayObject, I can't manipulate the stored ArrayObject, by getting it with offsetGet() Reproduce code: --------------- $array = new ArrayObject(); $subArray = new ArrayObject(); $array->append($subArray); $subArray->append('item'); var_dump($array); $array->offsetGet(0)->append('item2'); var_dump($array); Expected result: ---------------- object(ArrayObject)#23 (1) { [0]=> object(ArrayObject)#24 (1) { [0]=> string(4) "item" } } oobject(ArrayObject)#23 (1) { [0]=> object(ArrayObject)#24 (1) { [0]=> string(4) "item", [1]=> string(5) "item2" } } Actual result: -------------- object(ArrayObject)#23 (1) { [0]=> object(ArrayObject)#24 (1) { [0]=> string(4) "item" } } object(ArrayObject)#23 (1) { [0]=> NULL } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28831&edit=1