From cece391c57ab7800246fc5ebd788f0ec4c738322 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 15 Aug 2020 21:56:31 +0200 Subject: [PATCH] Update FoldLeft/FoldRight transformations. --- src/Transformation/FoldLeft.php | 6 +++--- src/Transformation/FoldRight.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Transformation/FoldLeft.php b/src/Transformation/FoldLeft.php index 4ccee1374..b2d8960ff 100644 --- a/src/Transformation/FoldLeft.php +++ b/src/Transformation/FoldLeft.php @@ -18,7 +18,7 @@ final class FoldLeft implements Transformation { /** * @var callable - * @psalm-var callable(T|null, T, TKey):(T|null) + * @psalm-var callable(T|null, T, TKey, \Iterator):(T|null) */ private $callback; @@ -29,7 +29,7 @@ final class FoldLeft implements Transformation private $initial; /** - * @psalm-param callable(T|null, T, TKey):(T|null) $callback + * @psalm-param callable(T|null, T, TKey, \Iterator):(T|null) $callback * * @param mixed|null $initial * @psalm-param T|null $initial @@ -52,7 +52,7 @@ public function __invoke(Iterator $collection) $initial = $this->initial; foreach ($collection as $key => $value) { - $initial = $callback($initial, $value, $key); + $initial = $callback($initial, $value, $key, $collection); } return $initial; diff --git a/src/Transformation/FoldRight.php b/src/Transformation/FoldRight.php index 7c60e46e0..ccbe78d81 100644 --- a/src/Transformation/FoldRight.php +++ b/src/Transformation/FoldRight.php @@ -19,7 +19,7 @@ final class FoldRight implements Transformation { /** * @var callable - * @psalm-var callable(T|null, T|null, TKey):(T|null) + * @psalm-var callable(T|null, T|null, TKey, \Iterator):(T|null) */ private $callback; @@ -30,7 +30,7 @@ final class FoldRight implements Transformation private $initial; /** - * @psalm-param callable(T|null, T|null, TKey):(T|null) $callback + * @psalm-param callable(T|null, T|null, TKey, \Iterator):(T|null) $callback * * @param mixed|null $initial * @psalm-param T|null $initial