1--TEST-- 2ReflectionEnum::getCases() 3--FILE-- 4<?php 5 6enum Enum_ { 7 case Foo; 8 case Bar; 9 const Baz = self::Bar; 10} 11 12enum IntEnum: int { 13 case Foo = 0; 14 case Bar = 1; 15 const Baz = self::Bar; 16} 17 18var_dump((new ReflectionEnum(Enum_::class))->getCases()); 19var_dump((new ReflectionEnum(IntEnum::class))->getCases()); 20 21?> 22--EXPECT-- 23array(2) { 24 [0]=> 25 object(ReflectionEnumUnitCase)#2 (2) { 26 ["name"]=> 27 string(3) "Foo" 28 ["class"]=> 29 string(5) "Enum_" 30 } 31 [1]=> 32 object(ReflectionEnumUnitCase)#3 (2) { 33 ["name"]=> 34 string(3) "Bar" 35 ["class"]=> 36 string(5) "Enum_" 37 } 38} 39array(2) { 40 [0]=> 41 object(ReflectionEnumBackedCase)#2 (2) { 42 ["name"]=> 43 string(3) "Foo" 44 ["class"]=> 45 string(7) "IntEnum" 46 } 47 [1]=> 48 object(ReflectionEnumBackedCase)#1 (2) { 49 ["name"]=> 50 string(3) "Bar" 51 ["class"]=> 52 string(7) "IntEnum" 53 } 54} 55