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

Attachment: OpenPGP_0x3936ABF753BC88CE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to