Re: Add __toArray() method to objects that would be called on cast to array
| From: | Andrey Andreev | Date: | Wed, 15 Mar 2017 23:53:24 +0000 |
| Subject: | Re: Add __toArray() method to objects that would be called on cast to array | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98558@lists.php.net to get a copy of this message | ||
Hi,
On Thu, Mar 16, 2017 at 1:33 AM, Marco Pivetta <ocramius@gmail.com> wrote:
> Correct: passing an object that implements
__toArray() to an
> API that
> uses an (array) cast internally will break or misbehave, if
> this feature
> is added to the language.
>
I'm not particularly interested in the idea anyway, but if you change
code and *then* something changes - that's not a BC break.
Also, I have to agree with Fleshgrinder on that we don't need more
magic methods and using an interface would be much cleaner.
Cheers,
Andrey.