Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 1.26 KB

reflection_enum.md

File metadata and controls

31 lines (23 loc) · 1.26 KB

ReflectionEnum

The ReflectionEnum class reports an information about an enum. This class is available in the standard PHP, so for any questions, please look at documentation for ReflectionEnum

Enum cases are represented by the ReflectionEnumUnitCase and ReflectionEnumBackedCase classes, which extend their native counterparts ReflectionEnumUnitCase and ReflectionEnumBackedCase.

Enum-specific API

final class ReflectionEnum extends \ReflectionEnum
{
    public function getBackingType(): ?ReflectionNamedType {}
    public function getCase(string $name): ReflectionEnumUnitCase|ReflectionEnumBackedCase {}
    public function getCases(): array {}
    public function hasCase(string $name): bool {}
    public function isBacked(): bool {}
}

But be careful, that several methods require the enum to be loaded into the memory, otherwise an exception will be thrown.

List of methods, that require enum to be loaded

  • ReflectionEnumUnitCase::getValue / ReflectionEnumBackedCase::getValue — Returns the concrete enum case object