Re: Add __toArray() method to objects that would be called on cast to array

From: Date: Wed, 15 Mar 2017 22:50:58 +0000
Subject: Re: Add __toArray() method to objects that would be called on cast to array
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-98552@lists.php.net to get a copy of this message
On 3/15/2017 11:40 PM, Marco Pivetta wrote: > Which is precisely the BC break: such a library would now throw an > exception "unsupported class X" when __toString is > implemented. Also, > such a library would break silently when this feature is implemented. > > Much like the already very broken __debugInfo(), this automatic > type-cast > is a giga-Joule footgun. I have to backup Ocramius here. As I already wrote, let's go for a totally normal implementation without any kind of magic. This is the only way to be safe, and the only way without adding more weirdness. All this special casing and magic only creates problems in short and long term. -- Richard "Fleshgrinder" Fussenegger

« previous php.internals (#98552) next »