Skip to content

Commit

Permalink
[Gen] support non-arraykey keys for generators/iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed Aug 22, 2020
1 parent d9543be commit 3573bda
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Psl/Gen/drop.php
Expand Up @@ -15,7 +15,7 @@
* Gen\drop([1, 2, 3, 4, 5], 3)
* => Gen(4, 5)
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to drop the elements from
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/drop_while.php
Expand Up @@ -17,7 +17,7 @@
* Gen\drop_while([3, 1, 4, -1, 5], fn($i) => $i > 0)
* => Gen(-1, 5)
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to drop values from
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/enumerate.php
Expand Up @@ -9,7 +9,7 @@
/**
* Converts an iterable of key and value pairs, into a generator of entries.
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/filter.php
Expand Up @@ -19,7 +19,7 @@
* Gen\filter(['foo', 'bar', 'baz', 'qux'], fn($value) => Str\contains($value, 'a'));
* => Gen('bar', 'baz')
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/filter_keys.php
Expand Up @@ -19,7 +19,7 @@
* Gen\filter_keys([0 => 'a', 1 => 'b', 2 => 'c'], fn($key) => $key <= 1);
* => Gen(0 => 'a', 1 => 'b')
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/filter_with_key.php
Expand Up @@ -19,7 +19,7 @@
* Gen\filter(['foo', 'bar', 'baz', 'qux'], fn($key, $value) => $key > 1 && Str\contains($value, 'a'));
* => Gen('baz')
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/from_keys.php
Expand Up @@ -10,7 +10,7 @@
* Returns a generator where each value is the result of calling the given
* function on the corresponding key.
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk> $keys
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/keys.php
Expand Up @@ -14,7 +14,7 @@
* Gen\keys(['a' => 0, 'b' => 1, 'c' => 2])
* => Gen('a', 'b', 'c')
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to get keys from
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/map.php
Expand Up @@ -18,7 +18,7 @@
* Gen\map([1, 2, 3, 4, 5], fn($i) => $i * 2);
* => Gen(2, 4, 6, 8, 10)
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
* @psalm-template T
*
Expand Down
4 changes: 2 additions & 2 deletions src/Psl/Gen/map_keys.php
Expand Up @@ -18,8 +18,8 @@
* Gen\map_keys([0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5], fn($i) => $i * 2);
* => Gen(0 => 1, 2 => 2, 4 => 3, 6 => 4, 8 => 5)
*
* @psalm-template Tk1 of array-key
* @psalm-template Tk2 of array-key
* @psalm-template Tk1
* @psalm-template Tk2
* @psalm-template Tv
*
* @psalm-param iterable<Tk1, Tv> $iterable Iterable to be mapped over
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/map_with_key.php
Expand Up @@ -17,7 +17,7 @@
* Gen\map_with_key([1, 2, 3, 4, 5], fn($k, $v) => $k + $v);
* => Gen(1, 3, 5, 7, 9)
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
* @psalm-template T
*
Expand Down
5 changes: 1 addition & 4 deletions src/Psl/Gen/pull.php
Expand Up @@ -24,11 +24,8 @@
* )
*
*
* k of array-key
* v
*
* @psalm-template T
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<T> $iterable
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/reductions.php
Expand Up @@ -15,7 +15,7 @@
*
* Reductions yield each accumulator along the way.
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
* @psalm-template Ts
*
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/take.php
Expand Up @@ -10,7 +10,7 @@
/**
* Take the first n elements from an iterable.
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/take_while.php
Expand Up @@ -17,7 +17,7 @@
* Gen\take_while([3, 1, 4, -1, 5], fn($i) => $i > 0)
* => Gen(3, 1, 4)
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to take values from
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/values.php
Expand Up @@ -17,7 +17,7 @@
* Gen\values([17 => 1, 42 => 2, -2 => 100])
* => Gen(1, 42, 100)
*
* @psalm-template Tk of array-key
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to get values from
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Gen/zip.php
Expand Up @@ -26,7 +26,7 @@
* @psalm-template Tk
* @psalm-template Tv
*
* @psalm-param iterable<iterable<Tk, Tv>> $iterables
* @psalm-param iterable<Tk, Tv> ...$iterables
*
* @psalm-return Generator<list<Tk>, list<Tv>, mixed, void>
*/
Expand Down

0 comments on commit 3573bda

Please sign in to comment.