Issues (172)

src/functions/iterable_reduce.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Improved;
6
7
/**
8
 * Reduce all elements to a single value using a callback.
9
 *
10
 * @param iterable  $iterable
11
 * @param callable  $callback
12
 * @param mixed     $initial
13
 * @return mixed
14
 */
15
function iterable_reduce(iterable $iterable, callable $callback, $initial = null)
0 ignored issues
show
Function Improved\iterable_reduce() has parameter $iterable with no value type specified in iterable type iterable.
Loading history...
16
{
17 11
    $result = $initial;
18
19 11
    foreach ($iterable as $key => $value) {
20 10
        $result = call_user_func($callback, $result, $value, $key);
21
    }
22
23 11
    return $result;
24
}
25