1--TEST--
2ZE2 ArrayAccess::offsetGet ambiguities
3--FILE--
4<?php
5class ObjectOne implements ArrayAccess {
6
7    public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
8
9    function offsetExists($index): bool {
10        echo __METHOD__ . "($index)\n";
11        return array_key_exists($index, $this->a);
12    }
13    function offsetGet($index): mixed {
14        echo __METHOD__ . "($index)\n";
15        switch($index) {
16        case 1:
17            $a = 'foo';
18            return $a . 'Bar';
19        case 2:
20            static $a=1;
21            return $a;
22        }
23        return $this->a[$index];
24    }
25    function offsetSet($index, $newval): void {
26        echo __METHOD__ . "($index,$newval)\n";
27        if ($index==3) {
28            $this->cnt = $newval;
29        }
30        $this->a[$index] = $newval;
31    }
32    function offsetUnset($index): void {
33        echo __METHOD__ . "($index)\n";
34        unset($this->a[$index]);
35    }
36}
37
38$obj = new ObjectOne;
39
40var_dump($obj[1]);
41var_dump($obj[2]);
42$obj[2]++;
43var_dump($obj[2]);
44
45?>
46--EXPECTF--
47ObjectOne::offsetGet(1)
48string(6) "fooBar"
49ObjectOne::offsetGet(2)
50int(1)
51ObjectOne::offsetGet(2)
52
53Notice: Indirect modification of overloaded element of ObjectOne has no effect in %sarray_access_004.php on line 39
54ObjectOne::offsetGet(2)
55int(1)
56