Skip to content

Reference

phil/enums
TypeRole
Traits\AsInvocableEnumTrait__invoke() and static case calls, both returning the case's primitive.
Traits\AsNameableEnumTraitnames(): the case names.
Traits\AsValuableEnumTraitvalues(): the case values, or the names of a pure enum.
Traits\AsSelectableEnumTraitoptions(): name to value for a backed enum, the names for a pure one.
Traits\AsStringSelectableEnumTraitstringOptions(): the options formatted by a callback and joined by a glue, HTML <option> elements by default, escaped and one per line.
Traits\AsComparableEnumTraitis(), isNot(), in(), notIn(), has(), doesntHave(), equalsOneOf(), notEqualsOneOf().
Traits\AsFromambleEnumTraitfrom() and tryFrom() by name for pure enums, fromName() and tryFromName() for every enum.
Traits\AsMetadatableEnumTraitMetadata accessors, fromMeta() and tryFromMeta(); an accessor no enabled meta property names throws BadMethodCallException.
Traits\AsSelfAwareableEnumTraitisPure(), isBacked(), isBackedByInteger(), isBackedByString().
Traits\AsCollectableEnumTraitcollect(), count(), first(), last(), filter(), whereMeta(), inGroup(), sortBy() on the enum.
Traits\AsOrdinalEnumTraitordinal(), next(), previous(), compareTo(), isBefore(), isAfter(), isBetween() (Order, parsing and defaults).
Traits\AsParsableEnumTraitparse() and tryParse(): by value, name or alias, with or without regard to letter case.
Traits\AsDefaultableEnumTraitdefault() and tryDefault(): the case marked #[DefaultCase].
Traits\AsStatefulEnumTraitcanTransitionTo(), nextStates(), isFinal(), initialStates(), transitions(): the moves #[TransitionsTo] declares.
Traits\AsEnumerableEnumTraitEvery trait except AsStringSelectableEnumTrait.
Sort\SortDirectionasc or desc, parsed leniently; its SQL keyword, its comparison, its reverse (Operations).
Collection\CaseCollectionAn immutable list of cases of one enum, with the operations (Operations).
Collection\EnumSetAn immutable set of cases of one enum, with set operations and bitmasks (Sets and maps).
Collection\EnumMapAn immutable map holding a value for every case of one enum (Sets and maps).
Attribute\MetaThe meta properties an enum, or a trait, declares.
Attribute\Description, Attribute\Group, Attribute\LabelMeta properties of string value, shipped with the library.
Attribute\AliasA repeatable meta property: another spelling parse() accepts.
Attribute\WeightA meta property: how often random() draws the case, 1 by default.
Attribute\DefaultCaseMarks the case default() returns.
Attribute\TransitionsToThe cases a case may move to.
Attribute\BitFlagsDeclares an enum of bit flags, checked by PHPStan.
Attribute\RequiredMetaThe meta properties every case must carry, checked by PHPStan and Reflection::missingRequiredMeta().
Meta\AbstractMetaPropertyThe base of a meta property: its value, transform(), defaultValue(), customMethodName(), method() and the static make().
Meta\ReflectionReads the meta properties of an enum, and the value — or every value, metaValueList() — of one on a case, once per enum and per case; the meta property an accessor reads, metaPropertyNamed(); whether a case is deprecated, the default case, the required metadata cases miss, a case's transitions, and parse() for any enum.
Exceptions\UndefinedCaseErrorA static call names no case of the enum.
Internal\CasesInternal: what the traits read from the cases — names, primitives, options — and the check that cases belong to an enum.
PHPStan\InvocableEnum\ReflectionExtension, PHPStan\MetadatableEnum\ReflectionExtensionThe PHPStan extensions (PHPStan).
PHPStan\VirtualMethodHow both extensions describe to PHPStan a method a trait answers through __call() or __callStatic().
PHPStan\RequiredMeta\RequiredMetaRuleThe PHPStan rule of #[RequiredMeta].
PHPStan\Declaration\EnumDeclarationRuleThe PHPStan rule of what an enum's attributes declare wrongly.
PHPStan\Ordinal\StoredOrdinalRuleThe PHPStan rule of an ordinal that leaves the process.