On 4 December 2025 04:50:57 GMT, Daniel Scherzer <[email protected]> wrote: >Hi internals, > >I'd like to start the discussion for a new RFC about removing the >prohibition on `__toString()` methods on enums. > >* RFC: https://wiki.php.net/rfc/stringable-enums >* Implementation: https://github.com/php/php-src/pull/20415
My first instinct was that this was dragging up a discussion we've had lots of times, but your examples make clear that you are *not* just talking about converting enums to their backing value. On the other hand, that does make me wonder: in what way is (string)$foo clearer than $foo->toString() for those use cases? In my experience, it just makes the functionality less discoverable - people don't think to try (string)$exception or (string)$simpleXmlNode, so miss that those have specific behaviour. And is it even a good name for those methods? In the date-time package, for instance, it would be better named toEnglishName() or getFullEnglishName(), as its docblock explicitly says. In the framework code, it seems to be used for a property called $displayValue, so the obvious name for the method would be getDisplayValue(). Regards, Rowan Tommins [IMSoP]
