Re: ::from() and tryFrom() on Basic Enums
| From: | Rowan Tommins [IMSoP] | Date: | Wed, 09 Jul 2025 22:21:35 +0000 |
| Subject: | Re: ::from() and tryFrom() on Basic Enums | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127982@lists.php.net to get a copy of this message | ||
On 09/07/2025 17:39, Deleu wrote:
It's currently undeniable that a Unit Enum name is a string.So is a class name, as accessed by $foo::class. $foo->name on an enum case is really just the same kind of pseudo-reflection, in my view: it's telling you information about the source code, useful primarily for debugging. If you want to associate a single string value with each enum case, use a string-backed enum, and propose some short-hand syntax. Please leave unit enums as opaque objects for those of us who see value in that. -- Rowan Tommins [IMSoP]