Re: [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode

From: Date: Fri, 23 Jan 2026 16:34:55 +0000
Subject: Re: [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-129901@lists.php.net to get a copy of this message
On 23 January 2026 16:05:28 GMT, Larry Garfield <larry@garfieldtech.com> wrote: >3. Unlike the other commenters, I am 100% in favor of allowing >string to accept Stringable in strict mode. Strict mode basically >broke Stringable, and that's been an annoyance for a long time. I know some feel that >Stringable is always and forever a bad thing, amen, but I don't agree. It has ample valid use >cases, even if it can be abused. I want my Stringable objects back! :-) I genuinely don't understand the reasoning here. If you want type coercion, why are you running in strict_types=1 mode? Why would you want to allow objects to be coerced, but not other values with unique, well-defined, string representations, like integers? Also, what do you mean by "strict mode broke Stringable"? Do you mean there was some code you wrote in PHP 5 that relied on implicit object-to-string conversion? It certainly wasn't called "Stringable" at the time; and it would have to have been internal functions, because users couldn't define "string" parameters. Rowan Tommins [IMSoP]

« previous php.internals (#129901) next »