Skip to content

Commit

Permalink
Update Psalm/typing annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 27, 2020
1 parent 6c3b94f commit d5207e3
Show file tree
Hide file tree
Showing 63 changed files with 150 additions and 145 deletions.
4 changes: 2 additions & 2 deletions src/Operation/Append.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<T> $items
*
* @psalm-return \Generator<TKey|int, T>
* @psalm-return Generator<TKey|int, T>
*/
static function (Iterator $iterator, array $items): Generator {
foreach ($iterator as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public function __construct(callable ...$callbacks)
}

/**
* @psalm-return \Closure(\Iterator<TKey, T>, list<callable(T, TKey):(bool)>):(\Generator<TKey, T>)
* @psalm-return Closure(Iterator<TKey, T>, list<callable(T, TKey):(bool)>):(Generator<TKey, T>)
*/
public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<callable(T, TKey):(bool)> $callbacks
*/
static function (Iterator $iterator, array $callbacks): Generator {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Associate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public function __construct(?callable $callbackForKeys = null, ?callable $callba
}

/**
* @psalm-return \Closure(\Iterator<TKey, T>, callable(TKey, T):(TKey), callable(TKey, T):(T)):(\Generator<TKey, T>)
* @psalm-return Closure(Iterator<TKey, T>, callable(TKey, T):(TKey), callable(TKey, T):(T)):(Generator<TKey, T>)
*/
public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param callable(TKey, T):(TKey) $callbackForKeys
* @psalm-param callable(TKey, T):(T) $callbackForValues
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, CacheItemPoolInterface $cache): Generator {
return yield from new CacheIterator($iterator, $cache);
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param ArrayIterator<int, int> $sizes
*
* @psalm-return \Generator<int, list<T>>
* @psalm-return Generator<int, list<T>>
*/
static function (Iterator $iterator, ArrayIterator $sizes): Generator {
$sizesIterator = (new Run(new Loop()))($sizes);
Expand Down
8 changes: 4 additions & 4 deletions src/Operation/Collapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<array-key, T|iterable<TKey, T>> $iterator
* @psalm-param Iterator<array-key, T|iterable<TKey, T>> $iterator
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator): Generator {
foreach ($iterator as $value) {
Expand All @@ -31,8 +31,8 @@ static function (Iterator $iterator): Generator {
}

/**
* @var TKey $subKey
* @var T $subValue
* @psalm-var TKey $subKey
* @psalm-var T $subValue
*/
foreach ($value as $subKey => $subValue) {
yield $subKey => $subValue;
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public function __construct($column)
}

/**
* @return \Closure(\Iterator<TKey, T>, array-key):(\Generator<int, iterable<TKey, T>>)
* @psalm-return Closure(Iterator<TKey, T>, array-key):(Generator<int, iterable<TKey, T>>)
*/
public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param array-key $column
*
* @psalm-return \Generator<int, iterable<TKey, T>>
* @psalm-return Generator<int, iterable<TKey, T>>
*
* @param mixed $column
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/Combinate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param callable(array<int, T>, int): (array<int, T>) $getCombinations
*
* @psalm-return \Generator<int, list<T>>
* @psalm-return Generator<int, list<T>>
*/
static function (Iterator $iterator, ?int $length, callable $getCombinations): Generator {
$dataset = iterator_to_array($iterator);
Expand All @@ -62,7 +62,7 @@ static function (Iterator $iterator, ?int $length, callable $getCombinations): G
* @psalm-param array<int, T> $dataset
*
* @return Generator<array<mixed>>
* @psalm-return \Generator<array<int, T>>
* @psalm-return Generator<array<int, T>>
*/
private function getCombinations(array $dataset, int $length): Generator
{
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Combine.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param ArrayIterator<int, TKey> $keys
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, ArrayIterator $keys): Generator {
while ($iterator->valid() && $keys->valid()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Compact.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<T|null> $values
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, array $values): Generator {
return yield from
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, int $length): Generator {
if (0 === $length) {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<T> $values
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, array $values): Generator {
foreach ($iterator as $key => $value) {
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/DiffKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<TKey> $values
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*
* @param mixed $values
*/
static function (Iterator $iterator, $values): Generator {
static function (Iterator $iterator, array $values): Generator {
foreach ($iterator as $key => $value) {
if (false === in_array($key, $values, true)) {
yield $key => $value;
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Distinct.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator): Generator {
$seen = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Explode.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<T> $explodes
*
* @psalm-return \Generator<int, list<T>>
* @psalm-return Generator<int, list<T>>
*/
static function (Iterator $iterator, array $explodes): Generator {
return yield from (new Run(
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param list<callable(T, TKey, \Iterator<TKey, T>):(bool)> $callbacks
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<callable(T, TKey, Iterator<TKey, T>):(bool)> $callbacks
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, array $callbacks): Generator {
yield from array_reduce(
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/First.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, callable $callback, int $size): Generator {
$callback =
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Flatten.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<int, T>
* @psalm-return Generator<int, T>
*/
static function (Iterator $iterator, int $depth): Generator {
foreach ($iterator as $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Flip.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<int|string, TKey>
* @psalm-return Generator<int|string, TKey>
*/
static function (Iterator $iterator): Generator {
foreach ($iterator as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Forget.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<TKey> $keys
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, array $keys): Generator {
$keys = array_flip($keys);
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Frequency.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<int, T>
* @psalm-return Generator<int, T>
*/
static function (Iterator $iterator): Generator {
$storage = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param callable(TKey, T):(TKey) $callable
*
* @psalm-return \Generator<int, list<T>>
* @psalm-return Generator<int, list<T>>
*/
static function (Iterator $iterator, callable $callable): Generator {
$data = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Intersect.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<T> $values
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator, array $values): Generator {
foreach ($iterator as $key => $value) {
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/IntersectKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
* @psalm-param list<TKey> $values
*
* @psalm-return \Generator<TKey, T>
* @psalm-return Generator<TKey, T>
*
* @param mixed $values
*/
static function (Iterator $iterator, $values): Generator {
static function (Iterator $iterator, array $values): Generator {
foreach ($iterator as $key => $value) {
if (false === in_array($key, $values, true)) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Intersperse.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @param mixed $element
* @psalm-param T $element
*
* @psalm-return \Generator<int|TKey, T>
* @psalm-return Generator<int|TKey, T>
*/
static function (Iterator $iterator, $element, int $every, int $startAt): Generator {
foreach ($iterator as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __invoke(): Closure
{
return
/**
* @psalm-param \Iterator<TKey, T> $iterator
* @psalm-param Iterator<TKey, T> $iterator
*
* @psalm-return \Generator<int, TKey>
* @psalm-return Generator<int, TKey>
*/
static function (Iterator $iterator): Generator {
foreach ($iterator as $key => $value) {
Expand Down

0 comments on commit d5207e3

Please sign in to comment.