mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
75a678a7e3
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
30 lines
553 B
PHP
30 lines
553 B
PHP
--TEST--
|
|
Enum offsetGet in constant expression
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo implements ArrayAccess {
|
|
case Bar;
|
|
|
|
public function offsetGet($key): mixed {
|
|
return 42;
|
|
}
|
|
|
|
public function offsetExists($key): bool {}
|
|
public function offsetSet($key, $value): void {}
|
|
public function offsetUnset($key): void {}
|
|
}
|
|
|
|
class X {
|
|
const FOO_BAR = Foo::Bar[0];
|
|
}
|
|
|
|
var_dump(X::FOO_BAR);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Uncaught Error: Cannot use [] on objects in constant expression in %s:%d
|
|
Stack trace:
|
|
#0 {main}
|
|
thrown in %s on line %d
|