Skip to content

Commit

Permalink
docs: Update annotations.
Browse files Browse the repository at this point in the history
Signed-off-by: Pol Dellaiera <pol.dellaiera@protonmail.com>
  • Loading branch information
drupol committed Oct 27, 2020
1 parent a080fae commit 7386746
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Contract/Operation/Pipeable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace loophp\collection\Contract\Operation;

use Generator;
use Iterator;
use loophp\collection\Contract\Collection;

/**
Expand All @@ -15,7 +16,7 @@
interface Pipeable
{
/**
* @psalm-param callable(): Generator ...$callables
* @psalm-param callable(Iterator<TKey, T>): Generator<TKey, T> ...$callables
*
* @psalm-return \loophp\collection\Contract\Collection<TKey, T>
*/
Expand Down
12 changes: 7 additions & 5 deletions src/Operation/Flatten.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
final class Flatten extends AbstractOperation
{
/**
* @psalm-return Closure(int): Closure(Iterator<TKey, T>): Generator<int, T>
* @psalm-return Closure(int): Closure(Iterator<TKey, T>): Generator<int|TKey, T>
*/
public function __invoke(): Closure
{
return
/**
* @psalm-return Closure(Iterator<TKey, T>): Generator<int, T>
* @psalm-return Closure(Iterator<TKey, T>): Generator<int|TKey, T>
*/
static function (int $depth): Closure {
return
/**
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return Generator<int, T>
* @psalm-return Generator<int|TKey, T>
*/
static function (Iterator $iterator) use ($depth): Generator {
foreach ($iterator as $key => $value) {
Expand All @@ -47,8 +47,10 @@ static function (Iterator $iterator) use ($depth): Generator {
$value = $flatten(new IterableIterator($value));
}

/** @psalm-var TKey $subKey */
/** @psalm-var T $subValue */
/**
* @psalm-var TKey $subKey
* @psalm-var T $subValue
*/
foreach ($value as $subKey => $subValue) {
yield $subKey => $subValue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Tails.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __invoke(): Closure
* @psalm-return Generator<int, array<TKey, T>, mixed, void>
*/
static function (Iterator $iterator): Generator {
/** @psalm-var Iterator<int, array{0: TKey, 1: T}> */
/** @psalm-var Iterator<int, array{0: TKey, 1: T}> $iterator */
$iterator = Pack::of()($iterator);
$data = iterator_to_array($iterator);

Expand Down

0 comments on commit 7386746

Please sign in to comment.