mirror of
https://github.com/php/php-src.git
synced 2026-04-24 08:28:26 +02:00
269c8dac1d
RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
51 lines
770 B
PHP
51 lines
770 B
PHP
--TEST--
|
|
Enum name property
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo {
|
|
case Bar;
|
|
case Baz;
|
|
}
|
|
|
|
enum IntFoo: int {
|
|
case Bar = 0;
|
|
case Baz = 1;
|
|
}
|
|
|
|
var_dump((new ReflectionClass(Foo::class))->getProperties());
|
|
var_dump(Foo::Bar->name);
|
|
|
|
var_dump((new ReflectionClass(IntFoo::class))->getProperties());
|
|
var_dump(IntFoo::Bar->name);
|
|
|
|
?>
|
|
--EXPECT--
|
|
array(1) {
|
|
[0]=>
|
|
object(ReflectionProperty)#2 (2) {
|
|
["name"]=>
|
|
string(4) "name"
|
|
["class"]=>
|
|
string(3) "Foo"
|
|
}
|
|
}
|
|
string(3) "Bar"
|
|
array(2) {
|
|
[0]=>
|
|
object(ReflectionProperty)#3 (2) {
|
|
["name"]=>
|
|
string(4) "name"
|
|
["class"]=>
|
|
string(6) "IntFoo"
|
|
}
|
|
[1]=>
|
|
object(ReflectionProperty)#4 (2) {
|
|
["name"]=>
|
|
string(5) "value"
|
|
["class"]=>
|
|
string(6) "IntFoo"
|
|
}
|
|
}
|
|
string(3) "Bar"
|