diff --git a/src/Operation/Unpack.php b/src/Operation/Unpack.php index 7b640bab6..11a3ee0ae 100644 --- a/src/Operation/Unpack.php +++ b/src/Operation/Unpack.php @@ -11,8 +11,6 @@ use Closure; use Generator; -use IteratorAggregate; -use loophp\iterators\IterableIteratorAggregate; use loophp\iterators\UnpackIterableAggregate; // phpcs:disable Generic.Files.LineLength.TooLong @@ -30,15 +28,10 @@ final class Unpack extends AbstractOperation */ public function __invoke(): Closure { - /** @var Closure(iterable): Generator $pipe */ - $pipe = (new Pipe())()( - (new Map())()(static fn (iterable $iterable): iterable => new IterableIteratorAggregate($iterable)), - (new Map())()((new Chunk())()(2)), - (new Flatten())()(1), - static fn (iterable $iterable): IteratorAggregate => new UnpackIterableAggregate($iterable) - ); - - // Point free style. - return $pipe; + return + /** + * @param iterable $iterable + */ + static fn (iterable $iterable): Generator => yield from new UnpackIterableAggregate($iterable); } } diff --git a/tests/unit/Traits/GenericCollectionProviders.php b/tests/unit/Traits/GenericCollectionProviders.php index a350b2578..e0d34a63e 100644 --- a/tests/unit/Traits/GenericCollectionProviders.php +++ b/tests/unit/Traits/GenericCollectionProviders.php @@ -4044,11 +4044,11 @@ public function unpackOperationProvider() $operation = 'unpack'; $input = [ - ['a', 'a'], - ['b', 'b'], - ['c', 'c'], - ['d', 'd'], - ['e', 'e'], + ['A', 'a'], + ['B', 'b'], + ['C', 'c'], + ['D', 'd'], + ['E', 'e'], ]; yield [ @@ -4056,30 +4056,11 @@ public function unpackOperationProvider() [], $input, [ - 'a' => 'a', - 'b' => 'b', - 'c' => 'c', - 'd' => 'd', - 'e' => 'e', - ], - ]; - - $input = [ - ['a', 'b', 'c' => 'c', 'd' => 'd'], - ['e', 'f', 'g' => 'g', 'h' => 'h'], - ['i', 'j'], - ]; - - yield [ - $operation, - [], - $input, - [ - 'a' => 'b', - 'c' => 'd', - 'e' => 'f', - 'g' => 'h', - 'i' => 'j', + 'A' => 'a', + 'B' => 'b', + 'C' => 'c', + 'D' => 'd', + 'E' => 'e', ], ]; }