Skip to content

Commit

Permalink
Update FoldLeft/FoldRight transformations.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 15, 2020
1 parent ddde5cc commit cece391
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Transformation/FoldLeft.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<TKey, T>):(T|null)
*/
private $callback;

Expand All @@ -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<TKey, T>):(T|null) $callback
*
* @param mixed|null $initial
* @psalm-param T|null $initial
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Transformation/FoldRight.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<TKey, T>):(T|null)
*/
private $callback;

Expand All @@ -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<TKey, T>):(T|null) $callback
*
* @param mixed|null $initial
* @psalm-param T|null $initial
Expand Down

0 comments on commit cece391

Please sign in to comment.