Skip to content

Commit

Permalink
Update Unpair operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 25, 2020
1 parent def5f26 commit 2d7ce6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions spec/loophp/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -1884,10 +1884,10 @@ public function it_can_unpair(): void
$this::fromIterable($input)
->unpair()
->shouldIterateAs([
['k1', 'v1'],
['k2', 'v2'],
['k3', 'v3'],
['k4', 'v4'],
'k1', 'v1',
'k2', 'v2',
'k3', 'v3',
'k4', 'v4',
]);
}

Expand Down
8 changes: 5 additions & 3 deletions src/Operation/Unpair.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<int, array{TKey, T}>
* @psalm-return Generator<int, array{TKey, T}>
*/
static function (Iterator $iterator): Generator {
foreach ($iterator as $key => $value) {
yield [$key, $value];
yield $key;

yield $value;
}
};
}
Expand Down

0 comments on commit 2d7ce6e

Please sign in to comment.