src/Type/StdTravers.php
function chain(\Closure $func, $default = null)
    {
        $i    = 0;
        $prev = $default;
        foreach ($this->getIterator() as $key => $val) {
            if ($i++ !== 0)
                $prev = $func($val, $key, $prev);
            else
                // use default value of argument of given closure
                $prev = $func($val, $key);

        }

        return $prev;
    }
function chain(\Closure $func, $default = null)
    {
        $i    = 0;
        $prev = $default;
        foreach ($this->getIterator() as $key => $val) {
            if ($i++ !== 0)
                $prev = $func($val, $key, $prev);
            else
                // use default value of argument of given closure
                $prev = $func($val, $key);

        }

        return $prev;
    }
function chain ( \ Closure $ func , $ default = null ) { $ i = 0 ; $ prev = $ default ; foreach ( $ this -> getIterator ( ) as $ key => $ val ) { if ( $ i ++ !== 0 ) $ prev = $ func ( $ val , $ key , $ prev ) ; else // use default value of argument of given closure $ prev = $ func ( $ val , $ key ) ; } return $ prev ; }
With Each Item

$prev is previous value that func return
@param \Closure $func fun($val, $key, $prev)

@return mixed
With Each Item