Re: Concept: "arrayable" pseudo type and \Arrayable interface
| From: | Aimeos | Norbert Sendetzky | Date: | Sun, 17 Nov 2019 16:35:24 +0000 |
| Subject: | Re: Concept: "arrayable" pseudo type and \Arrayable interface | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107809@lists.php.net to get a copy of this message | ||
>>> And if necessary, we can convert them to native arrays:
>>>
>>> if( $arrayable instanceof \Arrayable ) {
>>> $arrayable = $arrayable->toArray();
>>> }
>>
>> Also the toArray() should be called when an Arrayable is cast to an array:
>> (array)$arrayable.
>>
>> And shouldn’t the toArray match the same naming semantics as __toString?
>
> I proposed a while back adding a new magic method __toArray that
> would automatically cast. I'm halfway through writing the RFC (in
> draft and unpublished).
>
> I wonder how that could tie in to this proposal. Or even be a
> precursor to this.
Thank you for your very good suggestions!
@Steven: Can you please post the URL of your RFC?