Send a blank email to [email protected] to get a copy of this message
Hi all,
Enums are not allowed to include object properties and with property hooks it's now possible to define get-only dynamic properties.
I just come across the following example and wonder if this could be allowed in the future:
enum Month:int {
case January = 1;
case February = 2;
case March = 3;
case April = 4;
case May = 5;
case June = 6;
case July = 7;
case August = 8;
case September = 9;
case October = 10;
case November = 11;
case December = 12;
public string $abbreviation {
get => substr($this->name, 3);
}
}
Means, allowing get-only property hooks on enums reducing the need to write "old school" getter methods.
Is that something feasible and how complicated would that be to implement?
Best,
Marc Bennewitz