xref: /PHP-7.3/ext/spl/tests/bug32134.phpt (revision 782352c5)
1--TEST--
2Bug #32134 (Overloading offsetGet/offsetSet)
3--FILE--
4<?php
5
6class 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');
33var_dump($myArray->offsetGet('one'));
34
35$myArray['two'] = 'two';
36var_dump($myArray['two']);
37
38?>
39===DONE===
40<?php exit(0); ?>
41--EXPECT--
42myArray::offsetSet(one,one)
43myArray::offsetGet(one)
44string(3) "one"
45myArray::offsetSet(two,two)
46myArray::offsetGet(two)
47string(3) "two"
48===DONE===
49