Re: Re: [RFC] "arrayable" pseudo type hint

From: Date: Thu, 06 Feb 2020 11:59:45 +0000
Subject: Re: Re: [RFC] "arrayable" pseudo type hint
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-108411@lists.php.net to get a copy of this message
On Tue, Feb 4, 2020 at 7:40 PM Aimeos | Norbert Sendetzky < norbert@aimeos.com> wrote: > Am 04.02.20 um 19:17 schrieb Rowan Tommins: > > 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. > > What else besides array access, counting and traversing is possible that > may differ from classes that implement those interfaces? > > > 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". > > I think that's too complicated and we should make it as easy as possible > for PHP developers. > > Also, there's already an RFC for intersection types but it was never > adopted: https://wiki.php.net/rfc/intersection_types > FWIW, that's an old RFC that predates the current implementation of union types in PHP 8 by a few years... A new proposal for intersection types should stand a better chance now, especially as it can mostly reuse the (relatively involved) technical underpinnings for the union types implementation. Nikita

« previous php.internals (#108411) next »