Re: Internal iteration API

From: Date: Fri, 13 Jul 2012 17:30:32 +0000
Subject: Re: Internal iteration API
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-61210@lists.php.net to get a copy of this message
Hi! > Yep, today we have : > - arrays > - Object implementing ArrayAccess > - Objects implementing Traversable (Iterator) > - array_****() functions not working with ArrayAccess' objects > - Iterator API not working with arrays (ArrayIterator needed) > - ... I forget things > > There sure is something to do with that to make a consistent API. Definitely, having consistent generic iteration API would be great, and pretty much the only reason many iterative functions don't suport traversables is that there's no such API. As for ArrayAccess, it's more complicated. For example, if you have array_shift() I'm not sure ArrayAccess is enough to implement it. To find out "first" element you'd need Traversable, but even that won't allow you to "shift" array elements. So for some array_* functions only thing that you can rely on is an actual array... -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#61210) next »