Annotation of embedaddon/php/ext/spl/tests/bug33136.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #33136 (method offsetSet in class extended from ArrayObject crash PHP)
! 3: --FILE--
! 4: <?php
! 5:
! 6: class 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:
! 29: echo "\n\nInitiate Obj\n";
! 30: $arrayObj = new Collection();
! 31:
! 32: echo "Assign values\n";
! 33:
! 34: $arrayObj[] = "foo";
! 35: var_dump($arrayObj[0]);
! 36:
! 37: $arrayObj[] = "bar";
! 38: var_dump($arrayObj[0]);
! 39: var_dump($arrayObj[1]);
! 40:
! 41: $arrayObj["foo"] = "baz";
! 42: var_dump($arrayObj["foo"]);
! 43:
! 44: print_r($arrayObj);
! 45:
! 46: var_dump(count($arrayObj));
! 47:
! 48: ?>
! 49: ===DONE===
! 50: <?php //exit(0); ?>
! 51: --EXPECT--
! 52: Initiate Obj
! 53: Assign values
! 54: Collection::offsetSet(NULL,foo)
! 55: Collection::offsetGet(0)
! 56: string(3) "foo"
! 57: Collection::offsetSet(NULL,bar)
! 58: Collection::offsetGet(0)
! 59: string(3) "foo"
! 60: Collection::offsetGet(1)
! 61: string(3) "bar"
! 62: Collection::offsetSet(foo,baz)
! 63: Collection::offsetGet(foo)
! 64: string(3) "baz"
! 65: Collection 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: )
! 79: int(3)
! 80: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>