Hi

Den lør. 4. maj 2019 kl. 17.58 skrev Steven Wade <stevenwad...@gmail.com>:
>
> Hi Internals team!
>
> I have an idea for a feature that I'd love to see in the language one day and 
> wanted to run the idea by you all.
>
> The idea is to add a new magic method "__toArray()" that would allow a 
> developer to specifiy how a class is cast to an array. The idea is the same 
> mentality of __toString(), but, for arrays.

While this sounds great and all, I do wonder about the implications it
may have on the already existing behavior of type casting an object
into an array which returns current public/protected/private property
values. While this functionality is not an ideal or by design, it is
fairly heavily (ab-)used, meaning that it is a potential BC break
without the ability to an alternative.

See this example: https://3v4l.org/ONMoi

-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to