Hi

On 6/22/22 19:26, Larry Garfield wrote:
In case 1, I'd argue that the function should be switching to an Enum long term *and dropping the 
string*.  For that, a union type is the optimal solution.  Does that have BC implications for 
sub-classes?  Well, yes, but so does any type improvement.  This is a known problem space, with 
known solutions and migration strategies.  It's conceptually no different from migrating from 
"this takes a string" to "this takes an array of strings": Widen the type, have 
transitional code, retighten the type.  The time frame for that could be weeks, months, or years 
depending on the situation, but it's not a novel concept.

Exactly this. It might be painful for existing code, but I expect any newly written and any updated code to handle enums "natively" and so this is something that will solve itself over time.

On the other hand once the enum type safety is watered up by allowing implicit string conversions, there is no easy way to revert this.

Best regards
Tim Düsterhu

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

Reply via email to