ID:               34816
 Updated by:       [EMAIL PROTECTED]
 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

Reply via email to