Closed TysonAndre closed 3 years ago
We've come full circle ^^ Well, I would honestly just prefer keeping the case
property. It also technically makes more sense than keeping a hashmap for the case names.
Well, I would honestly just prefer keeping the
case
property.
Same.
That approach also makes it easier for libraries to attempt to partially polyfill this before 8.1 (e.g. also define public static function Hearts() { return self::Hearts; /* or something else in 8.0 and older */ }
)
(if code used the name)
@Crell As we've agreed to keep this property now after all, can you add it to the RFC?
->case is now added to the first section ("Unit Enums").
Possibly redundant since
case Hearts = 'Hearts'
can be used if you really want to use the name to identify cases, but after removing $value->name you'd need ReflectionEnumCase orexplode('::', var_export($value, true))[1]
if you wanted the enum name (e.g. for a debugging statement such asprintf("Handling %s\n", repr($enum))
Compiled languages often don't provide this, but dynamic ones might
get_enum_name(UnitEnum|ScalarEnum $value): string