diff --git a/spec/drupol/collection/CollectionSpec.php b/spec/drupol/collection/CollectionSpec.php index bf3a58774..046a10cef 100644 --- a/spec/drupol/collection/CollectionSpec.php +++ b/spec/drupol/collection/CollectionSpec.php @@ -229,7 +229,7 @@ public function it_can_chunk(): void $this::with(\range('A', 'F')) ->chunk(2) ->all() - ->shouldReturn([[0 => 'A', 1 => 'B'], [2 => 'C', 3 => 'D'], [4 => 'E', 5 => 'F']]); + ->shouldReturn([[0 => 'A', 1 => 'B'], [0 => 'C', 1 => 'D'], [0 => 'E', 1 => 'F']]); $this::with(\range('A', 'F')) ->chunk(0) @@ -239,7 +239,7 @@ public function it_can_chunk(): void $this::with(\range('A', 'F')) ->chunk(1) ->all() - ->shouldReturn([[0 => 'A'], [1 => 'B'], [2 => 'C'], [3 => 'D'], [4 => 'E'], [5 => 'F']]); + ->shouldReturn([[0 => 'A'], [0 => 'B'], [0 => 'C'], [0 => 'D'], [0 => 'E'], [0 => 'F']]); } public function it_can_collapse(): void diff --git a/src/Operation/Chunk.php b/src/Operation/Chunk.php index b88a3415e..d485d5383 100644 --- a/src/Operation/Chunk.php +++ b/src/Operation/Chunk.php @@ -44,7 +44,7 @@ public function on(iterable $collection): \Closure $iterator = new ClosureIterator( static function () use ($collection) { foreach ($collection as $key => $value) { - yield $key => $value; + yield $value; } } ); @@ -53,7 +53,7 @@ static function () use ($collection) { $values = []; for ($i = 0; $iterator->valid() && $i < $length; $i++, $iterator->next()) { - $values[$iterator->key()] = $iterator->current(); + $values[] = $iterator->current(); } yield new \ArrayIterator($values);