xref: /PHP-8.0/Zend/tests/objects_032.phpt (revision a555cc0b)
1--TEST--
2Covariant return-by-ref constraints
3--FILE--
4<?php
5
6class A implements ArrayAccess {
7    public $foo = array();
8
9    public function &offsetGet($n) {
10        return $this->foo[$n];
11    }
12
13    public function offsetSet($n, $v) {
14    }
15    public function offsetUnset($n) {
16    }
17    public function offsetExists($n) {
18    }
19}
20
21$a = new A;
22
23$a['foo']['bar'] = 2;
24
25var_dump($a);
26
27?>
28--EXPECT--
29object(A)#1 (1) {
30  ["foo"]=>
31  array(1) {
32    ["foo"]=>
33    array(1) {
34      ["bar"]=>
35      int(2)
36    }
37  }
38}
39