Re: [PHP-DEV] Enums should implement Stringable interface by default

2025-03-01 Thread AllenJB
So to summarize the proposed behavior (as I understand it): * If an enum is backed, it auto-casts to ->value * If an enum is not backed, it auto-casts to ->name I believe this has the following problems (at least): * Unbacked enums are not supposed to be representable as scalar values - if I,

Re: [PHP-DEV] Enums should implement Stringable interface by default

2025-02-28 Thread Larry Garfield
On Fri, Feb 28, 2025, at 10:11 AM, Rowan Tommins [IMSoP] wrote: > On 28/02/2025 08:33, Janis Kajaks wrote: >> My suggestion is that all enums (both basic/pure and backed) should >> implement Stringable interface by default, > > > This has come up at least twice before: > > * https://externals.io/m

Re: [PHP-DEV] Enums should implement Stringable interface by default

2025-02-28 Thread Rowan Tommins [IMSoP]
On 28/02/2025 08:33, Janis Kajaks wrote: My suggestion is that all enums (both basic/pure and backed) should implement Stringable interface by default, This has come up at least twice before: * https://externals.io/message/118040 * https://externals.io/message/124991 These threads also touch

[PHP-DEV] Enums should implement Stringable interface by default

2025-02-28 Thread Janis Kajaks
Hi, I'm writing this email with a reference to https://wiki.php.net/rfc/howto. My suggestion is that all enums (both basic/pure and backed) should implement Stringable interface by default, and before you say that it's totally wrong or impossible let me explain why. Let's say I have a backed enum: