1--TEST--
2Enum offsetGet in constant expression
3--FILE--
4<?php
5
6enum Foo implements ArrayAccess {
7    case Bar;
8
9    public function offsetGet($key): mixed {
10        return 42;
11    }
12
13    public function offsetExists($key): bool {}
14    public function offsetSet($key, $value): void {}
15    public function offsetUnset($key): void {}
16}
17
18class X {
19    const FOO_BAR = Foo::Bar[0];
20}
21
22var_dump(X::FOO_BAR);
23
24?>
25--EXPECTF--
26Fatal error: Uncaught Error: Cannot use [] on objects in constant expression in %s:%d
27Stack trace:
28#0 {main}
29  thrown in %s on line %d
30