Re: Consolidation of Traversable and array operations

From: Date: Wed, 15 Jul 2015 20:19:53 +0000
Subject: Re: Consolidation of Traversable and array operations
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-87190@lists.php.net to get a copy of this message
On Wed, Jul 15, 2015 at 9:53 PM, Rowan Collins <rowan.collins@gmail.com> wrote: > On 15 July 2015 20:39:05 GMT+01:00, Levi Morrison <levim@php.net> wrote: > >Do note that the union types RFC would also alleviate some of this > >pain for user-land functions, since array | Traversable > >would cover > >the required access pattern. I think this is a superior approach > >myself, but I may be a bit biased as I am authoring that proposal: > >https://wiki.php.net/rfc/union_types > > I like the idea of union types in general, but have always felt that a > typehint of Traversable should accept arrays as a matter of course. The > only thing such a typehint guarantees is that foreach will work (there are > no methods defined that can be called directly), and an array meets that > condition. The only difference I can see is in the passing / mutability > behaviour of objects vs non-objects. > But instanceof and anything related to Reflection or get_class or relevant code will fail on array. > > Regards, > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#87190) next »