Re: [RFC] [Under Discussion] Auto-implement Stringable for string backed enums

From: Date: Mon, 27 Jun 2022 16:54:51 +0000
Subject: Re: [RFC] [Under Discussion] Auto-implement Stringable for string backed enums
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-118109@lists.php.net to get a copy of this message
On Wed, Jun 22, 2022, at 12:26 PM, Larry Garfield wrote: > So I am firmly against making it easier to (mis)use enums in a > situation where constants are already the superior solution by every > metric. The only argument I see is making case 1, transitioning from a > string to an enum for a genuinely limited-case, easier. But in that > case, the transition is going to have to happen eventually anyway, and > that means the type is going to change at some point, and the same BC > issue will appear, just at a different time. Unless the intent is to > then never change the type and keep the function incorrectly typed > (from the POV that it's logically an enum, even though string typed was > the best/correct type for years) forever, in which case... use a set of > constants. > > --Larry Garfield As promised, a blog post on the topic that folks are welcome to link to when telling people no: https://peakd.com/hive-168588/@crell/on-the-use-of-enums --Larry Garfield

« previous php.internals (#118109) next »