1--TEST-- 2Bug #33136 (method offsetSet in class extended from ArrayObject crash PHP) 3--FILE-- 4<?php 5 6class Collection extends ArrayObject 7{ 8 private $data; 9 10 function __construct() 11 { 12 $this->data = array(); 13 parent::__construct($this->data); 14 } 15 16 function offsetGet($index) 17 { 18 echo __METHOD__ . "($index)\n"; 19 return parent::offsetGet($index); 20 } 21 22 function offsetSet($index, $value) 23 { 24 echo __METHOD__ . "(" . (is_null($index) ? "NULL" : $index) . ",$value)\n"; 25 parent::offsetSet($index, $value); 26 } 27} 28 29echo "\n\nInitiate Obj\n"; 30$arrayObj = new Collection(); 31 32echo "Assign values\n"; 33 34$arrayObj[] = "foo"; 35var_dump($arrayObj[0]); 36 37$arrayObj[] = "bar"; 38var_dump($arrayObj[0]); 39var_dump($arrayObj[1]); 40 41$arrayObj["foo"] = "baz"; 42var_dump($arrayObj["foo"]); 43 44print_r($arrayObj); 45 46var_dump(count($arrayObj)); 47 48?> 49===DONE=== 50<?php //exit(0); ?> 51--EXPECT-- 52Initiate Obj 53Assign values 54Collection::offsetSet(NULL,foo) 55Collection::offsetGet(0) 56string(3) "foo" 57Collection::offsetSet(NULL,bar) 58Collection::offsetGet(0) 59string(3) "foo" 60Collection::offsetGet(1) 61string(3) "bar" 62Collection::offsetSet(foo,baz) 63Collection::offsetGet(foo) 64string(3) "baz" 65Collection Object 66( 67 [data:Collection:private] => Array 68 ( 69 ) 70 71 [storage:ArrayObject:private] => Array 72 ( 73 [0] => foo 74 [1] => bar 75 [foo] => baz 76 ) 77 78) 79int(3) 80===DONE=== 81