name-property.phpt 770 B

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