diff --git a/src/Collection.php b/src/Collection.php index dd018a00f..e950d946d 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -670,7 +670,7 @@ public function partition(callable ...$callbacks): CollectionInterface return new self( Pipe::of()( Partition::of()(...$callbacks), - Map::of()(static fn (Iterator $iterator): CollectionInterface => self::fromIterable($iterator)) + Map::of()(static fn (array $callUserFuncParameters): CollectionInterface => self::fromCallable(...$callUserFuncParameters)), ), $this->getIterator() ); diff --git a/src/Operation/Partition.php b/src/Operation/Partition.php index f87194590..7361d0698 100644 --- a/src/Operation/Partition.php +++ b/src/Operation/Partition.php @@ -42,13 +42,9 @@ public function __invoke(): Closure * * @return Generator> */ - static function (Iterator $iterator) use ($callbacks): Iterator { - /** @var Iterator $filter */ - $filter = Filter::of()(...$callbacks)($iterator); - /** @var Iterator $reject */ - $reject = Reject::of()(...$callbacks)($iterator); - - return yield from [$filter, $reject]; - }; + static fn (Iterator $iterator): Generator => yield from [ + [Filter::of()(...$callbacks), $iterator], + [Reject::of()(...$callbacks), $iterator], + ]; } }