php-src/Zend/tests/enum/offsetGet-in-const-expr.phpt
Máté Kocsis 75a678a7e3
Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00

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