Skip to content

Commit

Permalink
refactor: Minor optimization in Pack operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jul 10, 2022
1 parent 0d4d7a2 commit 32462ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 6 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<files psalm-version="4.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
<file src="src/Collection.php">
<InvalidArgument occurrences="5">
<code>$callback</code>
Expand Down Expand Up @@ -43,4 +43,9 @@
<code>Closure(iterable&lt;TKey, T&gt;): Generator&lt;int, float&gt;</code>
</InvalidReturnType>
</file>
<file src="src/Operation/Pack.php">
<InvalidReturnType occurrences="1">
<code>Generator&lt;int, array{0: TKey, 1: T}&gt;</code>
</InvalidReturnType>
</file>
</files>
11 changes: 3 additions & 8 deletions src/Operation/Pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,16 @@
final class Pack extends AbstractOperation
{
/**
* @return Closure(iterable<TKey, T>): Generator<int, array{0: TKey, 1: T}>
* @return Closure(iterable<mixed, mixed>): Generator<int, array{0: TKey, 1: T}>
*/
public function __invoke(): Closure
{
return
/**
* @param iterable<TKey, T> $iterable
* @param iterable<mixed, mixed> $iterable
*
* @return Generator<int, array{0: TKey, 1: T}>
*/
static function (iterable $iterable): Generator {
/** @var PackIterableAggregate<TKey, T> $iterable */
$iterable = new PackIterableAggregate($iterable);

yield from $iterable->getIterator();
};
static fn (iterable $iterable): Generator => yield from new PackIterableAggregate($iterable);
}
}

0 comments on commit 32462ad

Please sign in to comment.