diff --git a/src/Operation/Transpose.php b/src/Operation/Transpose.php index 90423d756..7b82e67fe 100644 --- a/src/Operation/Transpose.php +++ b/src/Operation/Transpose.php @@ -11,7 +11,7 @@ use Closure; use Generator; -use loophp\iterators\IterableIteratorAggregate; +use loophp\iterators\MultipleIterableAggregate; use MultipleIterator; /** @@ -19,12 +19,12 @@ * * @template TKey * @template T + * + * phpcs:disable Generic.Files.LineLength.TooLong */ final class Transpose extends AbstractOperation { /** - * @psalm-suppress ImpureMethodCall - using MultipleIterator as an internal tool which is not returned - * * @return Closure(iterable): Generator> */ public function __invoke(): Closure @@ -47,14 +47,7 @@ public function __invoke(): Closure /** @var Closure(iterable): Generator> $pipe */ $pipe = (new Pipe())()( - (new Reduce())()( - static function (MultipleIterator $acc, iterable $iterable): MultipleIterator { - $acc->attachIterator((new IterableIteratorAggregate($iterable))->getIterator()); - - return $acc; - } - )(new MultipleIterator(MultipleIterator::MIT_NEED_ANY)), - (new Flatten())()(1), + static fn (iterable $iterables): MultipleIterableAggregate => new MultipleIterableAggregate($iterables, MultipleIterator::MIT_NEED_ANY), (new Associate())()($callbackForKeys)($callbackForValues) );