Re: What about a magic __toArray() method?
| From: | Marco Pivetta | Date: | Tue, 04 Feb 2020 10:37:25 +0000 |
| Subject: | Re: What about a magic __toArray() method? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108361@lists.php.net to get a copy of this message | ||
Hey Midori,
<http://ocramius.github.com/>
On Tue, Feb 4, 2020 at 11:35 AM Midori Koçak <mtkocak@gmail.com> wrote:
> Marco, I've read it and your argument is strong. I think my opinion
> slightly moves towards Andreas, away from magic.
>
> here is something I wrote some days ago:
> ö* ‘÷+U‹4�
> 5ÿ{https://github.com/midorikocak/arraytools/blob/master/src/ArrayConvertableTrait.php
>
> I guess you were saying something like this would be enough.
>
> Midori
>
>
Correct: an explicit
$foo->toArray() call suffices.
For other readers, more about $foo->toArray() vs (array) $foo is
described at
https://github.com/ShittySoft/symfony-live-berlin-2018-doctrine-tutorial/pull/3#issuecomment-460441229
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/