src/Map.php
public function reduce($reducer, $initial = null, $finisher = null)
    {
        $reduced = $initial;
        $this->walk(function ($value, $key) use ($reducer, &$reduced) {
            $reduced = $this->call($reducer, $reduced, $value, $key);
        });

        if (null === $finisher) {
            return $reduced;
        } else {
            return $this->call($finisher, $reduced);
        }
    }
public function reduce($reducer, $initial = null, $finisher = null)
    {
        $reduced = $initial;
        $this->walk(function ($value, $key) use ($reducer, &$reduced) {
            $reduced = $this->call($reducer, $reduced, $value, $key);
        });

        if (null === $finisher) {
            return $reduced;
        } else {
            return $this->call($finisher, $reduced);
        }
    }
public function reduce ( $ reducer , $ initial = null , $ finisher = null ) { $ reduced = $ initial ; $ this -> walk ( function ( $ value , $ key ) use ( $ reducer , & $ reduced ) { $ reduced = $ this -> call ( $ reducer , $ reduced , $ value , $ key ) ; } ) ; if ( null === $ finisher ) { return $ reduced ; } else { return $ this -> call ( $ finisher , $ reduced ) ; } }
Walk the map, applying a reducing expression to every element, so as to
reduce the map to a single value.

The `$reducer` expression receives three arguments:
- The current reduction (`$_0`)
- The current value (`$_1`)
- The current key (`$_2`)

The initial value, if given or null if not, is passed as the current
reduction on the first invocation of `$reducer`. The return value from
`$reducer` then becomes the new, current reduced value.

```
$nums = new Map(range(0, 3));
$sum = $nums->reduce('$_0 + $_1');
// $sum == 6
```

If `$finisher` is a callable or string expression, then it will be
called last, after iterating over all elements. It will be passed
reduced value. The `$finisher` must return the new final value.

@param callable|string $reducer
@param mixed $initial
@param callable|string|null $finisher
@return mixed
@api

@see http://php.net/manual/en/function.array-reduce.php
Walk the map applying a reducing expression to every element so as to reduce the map to a single value .