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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to