Bug #64431 [Opn]: SPL RecursiveArrayIterator::offsetSet with ArrayObject fails but stdClass works
| From: | namarpi at yahoo dot com | Date: | Sun, 17 Mar 2013 06:25:25 +0000 |
| Subject: | Bug #64431 [Opn]: SPL RecursiveArrayIterator::offsetSet with ArrayObject fails but stdClass works | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177843@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64431&edit=1
ID: 64431
User updated by: namarpi at yahoo dot com
Reported by: namarpi at yahoo dot com
Summary: SPL RecursiveArrayIterator::offsetSet with
ArrayObject fails but stdClass works
Status: Open
Type: Bug
Package: SPL related
Operating System: Windows
PHP Version: 5.4.13
Block user comment: N
Private report: N
New Comment:
Perhaps you have already faced with that too, that method chaining fails even with stdClass. If not
than this script provides an example:
https://github.com/namarpi/php-reports/blob/master/insertGrandchildByGrandparentKey.php
Previous Comments:
------------------------------------------------------------------------
[2013-03-16 07:36:00] namarpi at yahoo dot com
This test script gets rid of the RecursiveIteratorIterator, and focuses only on the
RecursiveArrayIterator.
https://github.com/namarpi/php-reports/blob/master/test-RecursiveArrayIterator::getChildren::offsetSet.php
------------------------------------------------------------------------
[2013-03-15 18:30:39] namarpi at yahoo dot com
Relocated the file to a GhitHub repository:
https://github.com/namarpi/php-reports/blob/master/test-RecursiveArrayIterator::offsetSet.txt
------------------------------------------------------------------------
[2013-03-15 15:29:44] namarpi at yahoo dot com
Description:
------------
Trying to modify an array through RecursiveIteratorIterator iterator. The successful modification
depends on how the array object was constructed.
Fails: $array_object = new ArrayObject( $array, 0, "RecursiveArrayIterator" );
Works: $object = json_decode( json_encode( $array ));
I am confused, because I expect the same behavior on both iterators. Attached a detailed test
script, which tells more than my bad English text. Maybe I am escaping something?
Test script:
---------------
http://madarak.net/php_reports/spl-recursion.txt
Expected result:
----------------
Modified ArrayObject object after using RecursiveArrayIterator::offsetSet/offsetUnset methods.
Actual result:
--------------
There are no effects on ArrayObject object after calling
RecursiveArrayIterator::offsetSet/offsetUnset methods.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64431&edit=1