Re: Re: [RFC] "arrayable" pseudo type hint
| From: | Rowan Tommins | Date: | Tue, 04 Feb 2020 18:17:40 +0000 |
| Subject: | Re: Re: [RFC] "arrayable" pseudo type hint | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108399@lists.php.net to get a copy of this message | ||
On Tue, 4 Feb 2020 at 18:06, Aimeos | Norbert Sendetzky <norbert@aimeos.com>
wrote:
> Am 04.02.20 um 18:18 schrieb Larry Garfield:
> > The more I think on it, the less I like
arrayable. PHP
> > arrays are
> > a terrible data structure from a type system point of view, with too
> > much functionality crammed into one variable type.
>
> The array internals are outside the scope of this proposal and are not
> affected in any way by this proposal.
>
I think Larry's point was that the flexibility of PHP's array type makes it
really hard to pin down whether a given object is "array-like" or not, and
which attributes a particular function actually cares about.
A general "intersection type" system might be more useful, because then you
could require the parts you specifically needed, such as
"traversable&ArrayAccess" or "traversable&countable".
Regards,
--
Rowan Tommins
[IMSoP]