mirror of
https://github.com/php/php-src.git
synced 2026-04-05 07:02:33 +02:00
RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
55 lines
874 B
PHP
55 lines
874 B
PHP
--TEST--
|
|
ReflectionEnum::getCases()
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Enum_ {
|
|
case Foo;
|
|
case Bar;
|
|
const Baz = self::Bar;
|
|
}
|
|
|
|
enum IntEnum: int {
|
|
case Foo = 0;
|
|
case Bar = 1;
|
|
const Baz = self::Bar;
|
|
}
|
|
|
|
var_dump((new ReflectionEnum(Enum_::class))->getCases());
|
|
var_dump((new ReflectionEnum(IntEnum::class))->getCases());
|
|
|
|
?>
|
|
--EXPECT--
|
|
array(2) {
|
|
[0]=>
|
|
object(ReflectionEnumUnitCase)#2 (2) {
|
|
["name"]=>
|
|
string(3) "Foo"
|
|
["class"]=>
|
|
string(5) "Enum_"
|
|
}
|
|
[1]=>
|
|
object(ReflectionEnumUnitCase)#3 (2) {
|
|
["name"]=>
|
|
string(3) "Bar"
|
|
["class"]=>
|
|
string(5) "Enum_"
|
|
}
|
|
}
|
|
array(2) {
|
|
[0]=>
|
|
object(ReflectionEnumBackedCase)#2 (2) {
|
|
["name"]=>
|
|
string(3) "Foo"
|
|
["class"]=>
|
|
string(7) "IntEnum"
|
|
}
|
|
[1]=>
|
|
object(ReflectionEnumBackedCase)#1 (2) {
|
|
["name"]=>
|
|
string(3) "Bar"
|
|
["class"]=>
|
|
string(7) "IntEnum"
|
|
}
|
|
}
|