mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00

RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
29 lines
528 B
PHP
29 lines
528 B
PHP
--TEST--
|
|
Enum offsetGet in constant expression
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo implements ArrayAccess {
|
|
case Bar;
|
|
|
|
public function offsetGet($key) {
|
|
return 42;
|
|
}
|
|
|
|
public function offsetExists($key) {}
|
|
public function offsetSet($key, $value) {}
|
|
public function offsetUnset($key) {}
|
|
}
|
|
|
|
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
|