From be33b493cc7af267ea0ea624dabb06ddeaf59f60 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 26 May 2020 23:21:56 +0200 Subject: [PATCH] Update Walk operation. --- src/Operation/Walk.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Operation/Walk.php b/src/Operation/Walk.php index 3d461e2fb..9dbe9a7b6 100644 --- a/src/Operation/Walk.php +++ b/src/Operation/Walk.php @@ -37,14 +37,12 @@ public function on(iterable $collection): Closure return static function () use ($callbacks, $collection): Generator { foreach ($collection as $key => $value) { - $carry = $value; - // Custom array_reduce function with the key passed in argument. foreach ($callbacks as $callback) { - $carry = $callback($carry, $key); + $value = $callback($value, $key); } - yield $key => $carry; + yield $key => $value; } }; }