Skip to content

Extension points

phil/enums

The library is plain PHP: it declares no service and no port. An application extends it through what its own enums declare.

PointHow
Behaviour on an enumThe traits: the aggregate, or the single traits an enum needs — see Installation
Metadata of the application's ownAn attribute class extending Phil\Enums\Meta\AbstractMetaProperty, listed in the enum's #[Meta(...)]; it may override transform(), defaultValue() and customMethodName() — see Metadata
Metadata brought by a traitA trait carrying its own #[Meta(...)]: its meta properties are read after the enum's, at run time and by PHPStan
Metadata every case must have#[RequiredMeta(...)] on the enum, reported by the PHPStan rule
Other names a case is parsed from#[Alias(...)] on the case
The case given when none is#[DefaultCase] on one case
Which cases follow which#[TransitionsTo(...)] on each case
Typing for PHPStanextension.neon, included by hand or automatically through phpstan/extension-installer — see PHPStan

The shipped meta properties — Label, Description, Group, Weight, Alias — are final: an application that wants another behaviour writes a meta property of its own rather than extending them.