Skip to content

Commit

Permalink
docs: Update typing information.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jan 9, 2021
1 parent 7502dc0 commit 861cb9f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
18 changes: 4 additions & 14 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,9 @@ public function associate(
* @param mixed $carry
* @psalm-param T|TKey $carry
*
* @param mixed $key
* @psalm-param TKey $key
*
* @param mixed $value
* @psalm-param T $value
*
* @psalm-return TKey|T
* @psalm-return T|TKey
*/
static fn ($carry, $key, $value) => $carry;
static fn ($carry) => $carry;

$callbackForKeys ??= $defaultCallback;
$callbackForValues ??= $defaultCallback;
Expand Down Expand Up @@ -455,11 +449,10 @@ public function ifThenElse(callable $condition, callable $then, ?callable $else
$else ??=
/**
* @psalm-param T $value
* @psalm-param TKey $key
*
* @psalm-return T
*/
static fn ($value, $key) => $value;
static fn ($value) => $value;

return new self(IfThenElse::of()($condition)($then)($else), $this->getIterator());
}
Expand Down Expand Up @@ -585,10 +578,7 @@ public function permutate(): CollectionInterface

public function pipe(callable ...$callables): self
{
return new self(
Pipe::of()(...$callables),
$this->getIterator()
);
return new self(Pipe::of()(...$callables), $this->getIterator());
}

public function pluck($pluck, $default = null): CollectionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Operation/Hasable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
interface Hasable
{
/**
* @psalm-param callable(T, TKey, Iterator<TKey, T>): bool $callback
* @psalm-param callable(T, TKey, Iterator<TKey, T>): bool ...$callbacks
*
* @psalm-return \loophp\collection\Collection<int, bool>
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Iterator/ProxyIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*
* @psalm-template TKey
* @psalm-template T
*
* @implements OuterIterator<TKey, T>
*/
abstract class ProxyIterator implements OuterIterator
{
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Flip.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __invoke(): Closure
*/
static fn ($carry, $key, $value) => $key;

/** @psalm-var Closure(Iterator<TKey, T>): Generator<T, TKey> $associate */
/** @psalm-var Closure(Iterator<TKey, T>): Closure(Iterator<TKey, T>): Generator<T, TKey> $associate */
$associate = Associate::of()($callbackForKeys)($callbackForValues);

// Point free style.
Expand Down
7 changes: 5 additions & 2 deletions src/Operation/Transpose.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __invoke(): Closure
*
* @psalm-return Generator<TKey, list<T>>
*/
static function (Iterator $iterator): Iterator {
static function (Iterator $iterator): Generator {
$mit = new MultipleIterator(MultipleIterator::MIT_NEED_ANY);

foreach ($iterator as $iterableIterator) {
Expand All @@ -54,7 +54,10 @@ static function (Iterator $iterator): Iterator {
*/
static fn (array $carry, array $key, array $value): array => $value;

return Associate::of()($callbackForKeys)($callbackForValues)($mit);
$associate = Associate::of()($callbackForKeys)($callbackForValues)($mit);

/** @psalm-var Generator<TKey, list<T>> $associate */
return $associate;
};
}
}

0 comments on commit 861cb9f

Please sign in to comment.