Re: [PHP-DEV] String enums & __toString()

2024-08-19 Thread Levi Morrison
On Fri, Aug 16, 2024 at 1:43 PM John Coggeshall wrote: > > Hey all, > > I poked around a bit in the Enum RFCs and I could find (maybe I missed) > what's up with this: > > enum Foo:string implements \Stringable > { > case FOO = 'bar'; > > public function __toString() { > return $th

Re: [PHP-DEV] String enums & __toString()

2024-08-17 Thread Bilge
On 17/08/2024 21:27, John Coggeshall wrote: would anyone have a strong objection to getting an RFC going to get this voted on? I don't think this is the right question to ask. Just write the RFC if you want to. If anyone objects, they will do so on the ML and at vote time, but it would be wro

Re: [PHP-DEV] String enums & __toString()

2024-08-17 Thread Gina P. Banyard
On Saturday, 17 August 2024 at 22:27, John Coggeshall wrote: > As it seems to me there isn't a particularly strong argument for why we don't > allow __toString() , would anyone have a strong objection to getting an RFC > going to get this voted on? I didn't look closely at the original PR from

Re: [PHP-DEV] String enums & __toString()

2024-08-17 Thread Rowan Tommins [IMSoP]
On 17 August 2024 21:27:59 BST, John Coggeshall wrote: > >I don't think it's without purpose... what it should be for is to allow >developers to make flexible APIs where they can type-hint string|Stringable >and the user of the API doesn't have to worry about it. My view is that the user *sh

Re: [PHP-DEV] String enums & __toString()

2024-08-17 Thread John Coggeshall
> Just to show the range of viewpoints on this, I'd like to mention my opinion > that Stringable is a horrible feature, with an implementation that's > completely inconsistent with the rest of the language, and no clear semantic > purpose. If your contract is "the input must be usable as a stri

Re: [PHP-DEV] String enums & __toString()

2024-08-17 Thread Rowan Tommins [IMSoP]
On 17 August 2024 01:47:20 BST, John Coggeshall wrote: > What's the point of a Stringable interface if we can't actually implement > __toString() for it? Just to show the range of viewpoints on this, I'd like to mention my opinion that Stringable is a horrible feature, with an implementatio

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread John Coggeshall
On Aug 16 2024, at 6:49 pm, Rob Landers wrote: > > That being said, I would like to be able to use | and & on integer enums more > than I would strings as stringables. Something like “flags” mode in C#. Maybe > even make “flag” a backing type of enums. It would make a ton of json flags > much

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread John Coggeshall
> To the original question, there's two reasons that __toString() was > deliberately omitted from enums: > > 1. To discourage their use as "fancy strings". Enums are their own type, > independent of any other. Making them usable as 95% strings partially defeats > their purpose. I disagree with

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Rob Landers
On Fri, Aug 16, 2024, at 21:57, John Coggeshall wrote: >> Didja really? >> >> https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums > I swear I did. > > That said, looking at that RFC it's a slightly different take than what I am > suggesting. This RFC suggests that `stri

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Larry Garfield
On Fri, Aug 16, 2024, at 5:01 PM, Bilge wrote: > On 16/08/2024 22:51, Gina P. Banyard wrote: >> On Friday, 16 August 2024 at 22:01, Bilge wrote: >>> >>> >>> On Fri, 16 Aug 2024, 20:57 John Coggeshall, wrote: I'm not seeing an obvious upside to forbidding straight out `__toString()`

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Bilge
On 16/08/2024 22:51, Gina P. Banyard wrote: On Friday, 16 August 2024 at 22:01, Bilge wrote: On Fri, 16 Aug 2024, 20:57 John Coggeshall, wrote: I'm not seeing an obvious upside to forbidding straight out |__toString()| I tend to agree, but Crell will drive by in a minute to drop

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Gina P. Banyard
On Friday, 16 August 2024 at 22:01, Bilge wrote: > On Fri, 16 Aug 2024, 20:57 John Coggeshall, wrote: > >> I'm not seeing an obvious upside to forbidding straight out __toString() > > I tend to agree, but Crell will drive by in a minute to drop some > philosophical nonsense about why we're all

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Faizan Akram Dar
On Fri, Aug 16, 2024, 11:22 PM Bilge wrote: > > > On Fri, 16 Aug 2024, 20:57 John Coggeshall, wrote: > >> >> I'm not seeing an obvious upside to forbidding straight out __toString() >> > > I tend to agree, but Crell will drive by in a minute to drop some > philosophical nonsense about why we're

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Bilge
On Fri, 16 Aug 2024, 20:57 John Coggeshall, wrote: > > I'm not seeing an obvious upside to forbidding straight out __toString() > I tend to agree, but Crell will drive by in a minute to drop some philosophical nonsense about why we're all wrong :^) Cheers, Bilge

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread John Coggeshall
> Didja really? > > https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums I swear I did. That said, looking at that RFC it's a slightly different take than what I am suggesting. This RFC suggests that string enums automatically implement Stringable . I am pointing out that i

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Eugene Sidelnyk
> > Didja really? > > https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums Why has it been withdrawn?

Re: [PHP-DEV] String enums & __toString()

2024-08-16 Thread Bilge
On 16/08/2024 20:39, John Coggeshall wrote: Hey all, I poked around a bit in the Enum RFCs and I could find (maybe I missed) what's up with this: Didja really? https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums