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