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

From: Date: Wed, 15 Mar 2017 22:51:03 +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-98553@lists.php.net to get a copy of this message
I was not aware of all that being the only way to distinguish set/unset properties. I do agree with Marco on this point that it would be a BC break. It was not my intention at all and did not foresee that. Up to now, I thought array casting objects was doing the same as for scalar values. I was wrong and I think many other developers around too. On Wed, 15 Mar 2017 at 23:40 Marco Pivetta <ocramius@gmail.com> 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. >

« previous php.internals (#98553) next »