Re: String enums & __toString()

From: Date: Fri, 16 Aug 2024 19:57:04 +0000
Subject: Re: String enums & __toString()
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-124994@lists.php.net to get a copy of this message
> Didja really? > > > https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums I swear I did. <shame> 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 it's a little silly IMO that we don't allow __toString() at all and let the developer choose if they want to implement Stringable . Looking through the PR comments it's pretty clear there was a decent amount of support for this alternative idea. It also looks like the PR for this died on the vine and I'm curious is there is any interest in reviving the discussion? I'm not seeing an obvious upside to forbidding straight out __toString() , especially (as is pointed out in the PR comments) that you can use other native interfaces like JsonSerializable without issue.

« previous php.internals (#124994) next »