Hi, On Wed, 2015-07-15 at 11:28 +0000, Tjerk Meesters wrote: > The most notable comment was that it would be nice to support Traversable > as well as arrays; instead of only supporting this for my own functions, > I've generalised this so that other functions can take advantage of this as > well. These are the additions: > > 1. A ZPP argument; the "t" (for traversable) argument type has been added > that checks for either an array or implementation of zend_ce_traversable. > > 2. A generic iteration function, called php_traverse(); it accepts: > a. the zval* to iterate over, > b. a step-wise function that receives the value and key, and returns a > boolean that determines whether iteration should continue or not, > c. a traversal mode (only values, or keys and values), > d. a context that's sent to the step-wise function.
I really like this concept to unify by access pattern, hiding the actual implementation! > 3. A concrete implementation of a step-wise iteration function, > php_traverse_until, that gets called as part of array_every() and > array_some(). I wonder if we can find a better naming scheme. For some array_ functions this will work, others not. This again feeds the "PHP is so inconsistent"-trolls. At the moment I'm leaning towards simply using every() and some_of() without reference to a type. Or maybe introduce, to restart the namespace-debate, php\every(), php\search(), php \someOf(), php\product(), etc. and deprecate array_search() etc. johannes
signature.asc
Description: This is a digitally signed message part