From 861cb9f1f593eea41ebafb40a761eabf606a95d3 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 9 Jan 2021 22:15:25 +0100 Subject: [PATCH] docs: Update typing information. --- src/Collection.php | 18 ++++-------------- src/Contract/Operation/Hasable.php | 2 +- src/Iterator/ProxyIterator.php | 2 -- src/Operation/Flip.php | 2 +- src/Operation/Transpose.php | 7 +++++-- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index 97693775b..9c62773db 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -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; @@ -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()); } @@ -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 diff --git a/src/Contract/Operation/Hasable.php b/src/Contract/Operation/Hasable.php index d7e62b497..f57b11817 100644 --- a/src/Contract/Operation/Hasable.php +++ b/src/Contract/Operation/Hasable.php @@ -15,7 +15,7 @@ interface Hasable { /** - * @psalm-param callable(T, TKey, Iterator): bool $callback + * @psalm-param callable(T, TKey, Iterator): bool ...$callbacks * * @psalm-return \loophp\collection\Collection */ diff --git a/src/Iterator/ProxyIterator.php b/src/Iterator/ProxyIterator.php index 4d3ad71a4..a68cd8d36 100644 --- a/src/Iterator/ProxyIterator.php +++ b/src/Iterator/ProxyIterator.php @@ -12,8 +12,6 @@ * * @psalm-template TKey * @psalm-template T - * - * @implements OuterIterator */ abstract class ProxyIterator implements OuterIterator { diff --git a/src/Operation/Flip.php b/src/Operation/Flip.php index 8516cf7ea..4d6cc6087 100644 --- a/src/Operation/Flip.php +++ b/src/Operation/Flip.php @@ -40,7 +40,7 @@ public function __invoke(): Closure */ static fn ($carry, $key, $value) => $key; - /** @psalm-var Closure(Iterator): Generator $associate */ + /** @psalm-var Closure(Iterator): Closure(Iterator): Generator $associate */ $associate = Associate::of()($callbackForKeys)($callbackForValues); // Point free style. diff --git a/src/Operation/Transpose.php b/src/Operation/Transpose.php index f9a0a8e9d..7337877a0 100644 --- a/src/Operation/Transpose.php +++ b/src/Operation/Transpose.php @@ -28,7 +28,7 @@ public function __invoke(): Closure * * @psalm-return Generator> */ - static function (Iterator $iterator): Iterator { + static function (Iterator $iterator): Generator { $mit = new MultipleIterator(MultipleIterator::MIT_NEED_ANY); foreach ($iterator as $iterableIterator) { @@ -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> $associate */ + return $associate; }; } }