Re: [RFC][Under discussion] Fetch properties in const expressions
| From: | Rowan Tommins | Date: | Mon, 27 Jun 2022 08:16:16 +0000 |
| Subject: | Re: [RFC][Under discussion] Fetch properties in const expressions | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118103@lists.php.net to get a copy of this message | ||
On 27/06/2022 08:38, Marc Bennewitz wrote:
Now as I have a lot of such classes and I want to make sure all of the prefixes are unique so I added an enum with all prefixes and use the enum value as constant value as well. enum IdPrefix:string {This would never have occurred to me as a design, because I had no idea that the values of backed enums were enforced to be unique. I'm not sure if it can be considered "taking advantage of a side-effect", or if people always expected backed enums to be used that way. Ultimately, that's my reaction to both the enum-related RFC currently under discussion: I don't really understand what backed enums are intended for in the first place, so find it hard to judge whether expanding them in a particular way makes sense. If a string-backed enum can be considered just a unique set of strings, then it really has very little in common with how I think of (unbacked) enums, but maybe that's fine. Regards, -- Rowan Tommins [IMSoP]case USER_ID = 'u-'; // ... }