String enums & __toString()

From: Date: Fri, 16 Aug 2024 19:39:33 +0000
Subject: String enums & __toString()
Groups: php.internals 
Request: Send a blank email to internals+get-124991@lists.php.net to get a copy of this message
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 $this->value; } } PHP Fatal error: Enum Foo cannot include magic method __toString It seems to me that when the enum is a string it is entirely reasonable to expect __toString() to work here and support the \Stringable interface. Is there a reason I'm missing as to why this is problematic in the engine that's been documented somewhere, or is this an oversight we can look at correcting? John

« previous php.internals (#124991) next »