2121 *
2222 * @psalm-immutable
2323 */
24- abstract class BackedEnumPolyfill implements BackedEnum
24+ abstract class EmulatedBackedEnum implements BackedEnum
2525{
2626 /**
2727 * The name of the current case
@@ -42,14 +42,14 @@ abstract class BackedEnumPolyfill implements BackedEnum
4242 /**
4343 * A map of case names and values by enumeration class
4444 *
45- * @var array<class-string<BackedEnumPolyfill >, array<string, int|string>>
45+ * @var array<class-string<EmulatedBackedEnum >, array<string, int|string>>
4646 */
4747 private static $ caseConstants = [];
4848
4949 /**
5050 * A map of case names and instances by enumeration class
5151 *
52- * @var array<class-string<BackedEnumPolyfill >, array<string, BackedEnumPolyfill >>
52+ * @var array<class-string<EmulatedBackedEnum >, array<string, EmulatedBackedEnum >>
5353 */
5454 private static $ cases = [];
5555
@@ -129,13 +129,13 @@ final public static function from($value): BackedEnum
129129
130130 $ name = \array_search ($ value , self ::$ caseConstants [static ::class], true );
131131 if ($ name === false ) {
132- if (\is_subclass_of (static ::class, IntEnumPolyfill ::class)) {
132+ if (\is_subclass_of (static ::class, IntBackedEnum ::class)) {
133133 if (!\is_int ($ value )) {
134134 throw new TypeError (static ::class . '::from(): Argument #1 ($value) must be of type int, ' . \get_debug_type ($ value ) . ' given ' );
135135 }
136136
137137 throw new ValueError ("{$ value } is not a valid backing value for enum \"" . static ::class . '" ' );
138- } elseif (\is_subclass_of (static ::class, StringEnumPolyfill ::class)) {
138+ } elseif (\is_subclass_of (static ::class, StringBackedEnum ::class)) {
139139 if (!\is_string ($ value )) {
140140 throw new TypeError (static ::class . '::from(): Argument #1 ($value) must be of type string, ' . \get_debug_type ($ value ) . ' given ' );
141141 }
@@ -214,8 +214,8 @@ private static function init(string $enumClass)
214214 $ cases = [];
215215 foreach ($ caseConstants as $ name => $ value ) {
216216 assert (
217- (\is_subclass_of ($ enumClass , IntEnumPolyfill ::class) && \is_int ($ value ))
218- || (\is_subclass_of ($ enumClass , StringEnumPolyfill ::class) && \is_string ($ value )),
217+ (\is_subclass_of ($ enumClass , IntBackedEnum ::class) && \is_int ($ value ))
218+ || (\is_subclass_of ($ enumClass , StringBackedEnum ::class) && \is_string ($ value )),
219219 "Enum case constant \"{$ enumClass }:: {$ name }\" does not match enum backing type "
220220 );
221221
0 commit comments