A case is a singleton, so a mutable property on it would be shared by every reference in the process, and the language forbids properties outright rather than trusting anybody.
enum Tier: string
{
case Gold = 'gold';
public $discount; // Fatal: Enum "Tier" cannot include
// properties
}
// what to do instead: a method, computed from the case
enum Tier: string
{
case Gold = 'gold';
public function discountBasisPoints(): int
{
return match ($this) { self::Gold => 1500 };
}
}
The instinct to attach data to a case is right and the mechanism is a method rather than a property, which has the useful side effect of making the data derivable rather than assignable. When the data genuinely varies at runtime — a discount that an administrator can change — the enum is the key and a table holds the value, which is the arrangement that survives the first configuration request.