xref: /PHP-8.2/Zend/tests/enum/name-property.phpt (revision 269c8dac)
1--TEST--
2Enum name property
3--FILE--
4<?php
5
6enum Foo {
7    case Bar;
8    case Baz;
9}
10
11enum IntFoo: int {
12    case Bar = 0;
13    case Baz = 1;
14}
15
16var_dump((new ReflectionClass(Foo::class))->getProperties());
17var_dump(Foo::Bar->name);
18
19var_dump((new ReflectionClass(IntFoo::class))->getProperties());
20var_dump(IntFoo::Bar->name);
21
22?>
23--EXPECT--
24array(1) {
25  [0]=>
26  object(ReflectionProperty)#2 (2) {
27    ["name"]=>
28    string(4) "name"
29    ["class"]=>
30    string(3) "Foo"
31  }
32}
33string(3) "Bar"
34array(2) {
35  [0]=>
36  object(ReflectionProperty)#3 (2) {
37    ["name"]=>
38    string(4) "name"
39    ["class"]=>
40    string(6) "IntFoo"
41  }
42  [1]=>
43  object(ReflectionProperty)#4 (2) {
44    ["name"]=>
45    string(5) "value"
46    ["class"]=>
47    string(6) "IntFoo"
48  }
49}
50string(3) "Bar"
51