Annotation of embedaddon/php/ext/spl/tests/bug32134.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #32134 (Overloading offsetGet/offsetSet)
! 3: --FILE--
! 4: <?php
! 5:
! 6: class myArray extends ArrayIterator
! 7: {
! 8:
! 9: public function __construct($array = array())
! 10: {
! 11: parent::__construct($array);
! 12: }
! 13:
! 14: public function offsetGet($index)
! 15: {
! 16: static $i = 0;
! 17: echo __METHOD__ . "($index)\n";
! 18: if (++$i > 3) exit(1);
! 19: return parent::offsetGet($index);
! 20: }
! 21:
! 22: public function offsetSet($index, $newval)
! 23: {
! 24: echo __METHOD__ . "($index,$newval)\n";
! 25: return parent::offsetSet($index, $newval);
! 26: }
! 27:
! 28: }
! 29:
! 30: $myArray = new myArray();
! 31:
! 32: $myArray->offsetSet('one', 'one');
! 33: var_dump($myArray->offsetGet('one'));
! 34:
! 35: $myArray['two'] = 'two';
! 36: var_dump($myArray['two']);
! 37:
! 38: ?>
! 39: ===DONE===
! 40: <?php exit(0); ?>
! 41: --EXPECT--
! 42: myArray::offsetSet(one,one)
! 43: myArray::offsetGet(one)
! 44: string(3) "one"
! 45: myArray::offsetSet(two,two)
! 46: myArray::offsetGet(two)
! 47: string(3) "two"
! 48: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>