1--TEST--
2Array offset on ArrayAccess object in virtual property is allowed
3--FILE--
4<?php
5
6class Collection implements ArrayAccess {
7    public function offsetExists(mixed $offset): bool {
8        echo __METHOD__ . "\n";
9        return true;
10    }
11
12    public function offsetGet(mixed $offset): mixed {
13        echo __METHOD__ . "\n";
14        return true;
15    }
16
17    public function offsetSet(mixed $offset, mixed $value): void {
18        echo __METHOD__ . "\n";
19    }
20
21    public function offsetUnset(mixed $offset): void {
22        echo __METHOD__ . "\n";
23    }
24}
25
26class C {
27    public function __construct(
28        public Collection $collection = new Collection(),
29    ) {}
30    public $prop {
31        get => $this->collection;
32    }
33}
34
35$c = new C();
36var_dump($c->prop['foo']);
37var_dump($c->prop[] = 'foo');
38var_dump(isset($c->prop['foo']));
39unset($c->prop['foo']);
40
41?>
42--EXPECT--
43Collection::offsetGet
44bool(true)
45Collection::offsetSet
46string(3) "foo"
47Collection::offsetExists
48bool(true)
49Collection::offsetUnset
50