Merge pull request #11 from azjezz/as-of

use `of` instead of `as` for generic type constrain
This commit is contained in:
Saif Eddin G 2020-02-19 15:02:28 +01:00 committed by GitHub
commit f4188365bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 71 additions and 71 deletions

View File

@ -10,7 +10,7 @@ use Psl;
* Retrieve a value from the array using the given key.
* If the key doesn't exist, an InvariantViolationException will be thrown.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Returns true if the given array contains the key.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -12,7 +12,7 @@ use Psl\Str;
* Returns a new array mapping each value to the number of times it appears
* in the given iterable.
*
* @psalm-template Tv as array-key
* @psalm-template Tv of array-key
*
* @psalm-param iterable<Tv> $values
*

View File

@ -10,7 +10,7 @@ use Psl\Iter;
* Returns whether the two given arrays have the same entries, using strict
* equality. To guarantee equality of order as well as contents, use `===`.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Get the first value of an array, If the array is empty, null will be returned.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Get the first key of an array, if the array is empty, null will be returned.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
*
* @psalm-param array<Tk, mixed> $array
*

View File

@ -10,7 +10,7 @@ use Psl;
* Get the first value of an array, If the array is empty, an InvariantViolationException
* will be thrown.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -16,7 +16,7 @@ namespace Psl\Arr;
* Arr\flatten([[0 => 1, 1 => 2], [2 => 9, 3 => 8]])
* => Arr(0 => 1, 1 => 2, 2 => 9, 3 => 8)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<iterable<Tk, Tv>> $iterables

View File

@ -16,8 +16,8 @@ use Psl\Str;
* Iter\flip(['a' => 1, 'b' => 2, 'c' => 3])
* => Iter(1 => 'a', 2 => 'b', 3 => 'c')
*
* @psalm-template Tk as array-key
* @psalm-template Tv as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv of array-key
*
* @psalm-param iterable<Tk, Tv> $iterable
*

View File

@ -27,7 +27,7 @@ use Psl\Str;
* )
* => Arr(7 => [2], 8 => [3], 9 => [4], 10 => [5], 11 => [6], 12 => [7, 8, 9, 10])
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tv> $values

View File

@ -19,7 +19,7 @@ namespace Psl\Arr;
* Arr\contains_key($array, $index) ? $array[$index] : $default;
* ```
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Return all the keys of an array.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $arr

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Get the last value of an array, if the array is empty, returns null.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Get the last key of an array, if the array is empty, null will be returned.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -10,7 +10,7 @@ use Psl;
* Get the last value of an array, If the array is empty, an InvariantViolationException
* will be thrown.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -15,7 +15,7 @@ namespace Psl\Arr;
* Arr\merge([0 => 1, 1 => 2], [2 => 9, 3 => 8])
* => Arr(0 => 1, 1 => 2, 2 => 9, 3 => 8)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $first

View File

@ -11,7 +11,7 @@ use Psl\Random;
/**
* Retrieve a random value from a non-empty array.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $values

View File

@ -9,7 +9,7 @@ namespace Psl\Arr;
* and the given iterable. The array will have the same ordering as the
* `$keys` iterable.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -17,7 +17,7 @@ use Psl;
* Arr\shuffle('a' => 1, 'b' => 2, 'c' => 3)
* => Arr(2, 3, 1)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -11,7 +11,7 @@ use Psl\Iter;
* optional comparator function isn't provided, the values will be sorted in
* ascending order.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -12,7 +12,7 @@ use Psl\Iter;
* comparator function isn't provided, the values will be sorted in ascending
* order of scalar key.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template Ts
*

View File

@ -11,7 +11,7 @@ use Psl\Iter;
* optional comparator function isn't provided, the keys will be sorted in
* ascending order.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -11,7 +11,7 @@ use Psl\Iter;
* optional comparator function isn't provided, the values will be sorted in
* ascending order ( maintains index association ).
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -12,7 +12,7 @@ use Psl\Iter;
* comparator function isn't provided, the values will be sorted in ascending
* order of scalar key.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template Ts
*

View File

@ -7,7 +7,7 @@ namespace Psl\Arr;
/**
* Returns a new array in which each value appears exactly once.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -13,9 +13,9 @@ use Psl\Str;
* value's uniqueness is determined by transforming it to a scalar via the
* given function.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template Ts as array-key
* @psalm-template Ts of array-key
*
* @psalm-param iterable<Tk, Tv> $iterable
* @psalm-param (callable(Tv): Ts) $scalar_func

View File

@ -9,7 +9,7 @@ use IteratorAggregate;
/**
* Interface ConstMap.
*
* @template Tk as array-key
* @template Tk of array-key
* @template Tv
*
* @extends ConstCollection<Pair<Tk, Tv>>

View File

@ -7,7 +7,7 @@ namespace Psl\Collection;
/**
* The interface for all Sets to enable access its values.
*
* @template Tv as array-key
* @template Tv of array-key
*/
interface ConstSetAccess
{

View File

@ -8,7 +8,7 @@ use Psl;
use Psl\Iter;
/**
* @template Tk as array-key
* @template Tk of array-key
* @template Tv
*
* @implements ConstMap<Tk, Tv>

View File

@ -24,7 +24,7 @@ use Psl\Iter;
* are being removed. When a new key is added or an element is removed, all
* iterators that point to the `Map` shall be considered invalid.
*
* @template Tk as array-key
* @template Tk of array-key
* @template Tv
*
* @implements MutableMap<Tk, Tv>

View File

@ -11,7 +11,7 @@ namespace Psl\Collection;
* defined in its parent interfaces. But you could theoretically use this
* interface for parameter and return type annotations.
*
* @template Tk as array-key
* @template Tk of array-key
* @template Tv
*
* @extends ConstMapAccess<Tk, Tv>

View File

@ -7,7 +7,7 @@ namespace Psl\Collection;
/**
* Represents a write-enabled (mutable) sequence of key/value pairs (ie. map).
*
* @template Tk as array-key
* @template Tk of array-key
* @template Tv
*
* @extends ConstMap<Tk, Tv>

View File

@ -7,7 +7,7 @@ namespace Psl\Collection;
/**
* The interface for mutable `Set`s to enable removal of its values.
*
* @template Tv as array-key
* @template Tv of array-key
*
* @extends ConstSetAccess<Tv>
*/

View File

@ -17,7 +17,7 @@ use Generator;
* Iter\chain(Iterable\range(0, 5), Iter\range(6, 10), Iter\range(11, 15))
* => Iter(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> ...$iterables Iterables to chain

View File

@ -9,7 +9,7 @@ use Psl\Arr;
/**
* Returns true if the given iterable contains the key.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable,

View File

@ -9,7 +9,7 @@ use Generator;
use Psl\Arr;
/**
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $first

View File

@ -12,7 +12,7 @@ namespace Psl\Iter;
* Iter\drop([1, 2, 3, 4, 5], 3)
* => Iter(4, 5)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk,Tv> $iterable Iterable to drop the elements from

View File

@ -17,7 +17,7 @@ use Generator;
* Iter\drop_while([3, 1, 4, -1, 5], fm($i) => $i > 0)
* => Iter(-1, 5)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to drop values from

View File

@ -9,7 +9,7 @@ use Generator;
/**
* Converts an iterable of key and value pairs, into an iterable of entries.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -19,7 +19,7 @@ use Generator;
* Iter\filter(['foo', 'bar', 'baz', 'qux'], fn($value) => Str\contains($value, 'a'));
* => Iter('bar', 'baz')
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -19,7 +19,7 @@ use Generator;
* Iter\filter_keys([0 => 'a', 1 => 'b', 2 => 'c'], fn($key) => $key <= 1);
* => Iter(0 => 'a', 1 => 'b')
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -19,7 +19,7 @@ use Psl;
* Iter\filter(['foo', 'bar', 'baz', 'qux'], fn($key, $value) => $key > 1 && Str\contains($value, 'a'));
* => Iter('baz')
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -22,7 +22,7 @@ use Psl\Arr;
* Iter\first_key([])
* => Null
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -10,7 +10,7 @@ use Generator;
* Returns a new dict formed by merging the iterable elements of the
* given iterable.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<iterable<Tk, Tv>> $iterables

View File

@ -10,7 +10,7 @@ use Generator;
* Returns a new dict where each mapping is defined by the given key/value
* tuples.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<array{0: Tk, 1: Tv}> $entries

View File

@ -10,7 +10,7 @@ use Generator;
* Returns a new dict where each value is the result of calling the given
* function on the corresponding key.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk> $keys

View File

@ -14,7 +14,7 @@ use Generator;
* Iter\keys(['a' => 0, 'b' => 1, 'c' => 2])
* => Iter('a', 'b', 'c')
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to get keys from

View File

@ -9,7 +9,7 @@ use Psl\Arr;
/**
* Get the last value of an iterable, if the iterable is empty, returns null.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -9,7 +9,7 @@ use Psl\Arr;
/**
* Get the last key of an iterable, if the iterable is empty, null will be returned.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array

View File

@ -18,7 +18,7 @@ use Generator;
* Iter\map([1, 2, 3, 4, 5], fn($i) => $i * 2);
* => Iter(2, 4, 6, 8, 10)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template T
*

View File

@ -18,8 +18,8 @@ use Generator;
* Iter\map_keys([0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5], fn($i) => $i * 2);
* => Iter(0 => 1, 2 => 2, 4 => 3, 6 => 4, 8 => 5)
*
* @psalm-template Tk1 as array-key
* @psalm-template Tk2 as array-key
* @psalm-template Tk1 of array-key
* @psalm-template Tk2 of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk1, Tv> $iterable Iterable to be mapped over

View File

@ -17,7 +17,7 @@ use Generator;
* Iter\map_with_key([1, 2, 3, 4, 5], fn($k, $v) => $k + $v);
* => Iter(1, 3, 5, 7, 9)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template T
*

View File

@ -24,11 +24,11 @@ use Generator;
* )
*
*
* k as array-key
* k of array-key
* v
*
* @psalm-template T
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<T> $iterable

View File

@ -23,9 +23,9 @@ use Generator;
* 70 => 'H', 131 => 'I', 264 => 'J', 521 => 'K', 1034 => 'L'
* )
*
* @psalm-template Tk1 as array-key
* @psalm-template Tk1 of array-key
* @psalm-template Tv1
* @psalm-template Tk2 as array-key
* @psalm-template Tk2 of array-key
* @psalm-template Tv2
*
* @psalm-param iterable<Tk1, Tv1> $iterable

View File

@ -10,7 +10,7 @@ use Psl\Arr;
/**
* Retrieve a random value from a non-empty iterable.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -19,7 +19,7 @@ namespace Psl\Iter;
* Iter\reduce(Iter\range(1, 5), fn($accumulator, $value) => $accumulator * $value, 1)
* => 120
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template Ts
*

View File

@ -15,7 +15,7 @@ use Generator;
*
* Reductions yield each accumulator along the way.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
* @psalm-template Ts
*

View File

@ -26,8 +26,8 @@ use Generator;
* 24 => ['id' => 24, 'name' => 'bar']
* )
*
* @psalm-template Tk1 as array-key
* @psalm-template Tk2 as array-key
* @psalm-template Tk1 of array-key
* @psalm-template Tk2 of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk1, Tv> $iterable Iterable to reindex

View File

@ -18,7 +18,7 @@ use Psl;
* IterIter\slice([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], 5, 3)
* => Iter(0, 1, 2, 3)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk,Tv> $iterable Iterable to take the slice from

View File

@ -7,7 +7,7 @@ namespace Psl\Iter;
/**
* Take the first n elements from an iterable.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -17,7 +17,7 @@ use Generator;
* Iter\take_while([3, 1, 4, -1, 5], fn($i) => $i > 0)
* => iter(3, 1, 4)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to take values from

View File

@ -7,7 +7,7 @@ namespace Psl\Iter;
/**
* Copy the iterable into an array with keys.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -10,7 +10,7 @@ use IteratorAggregate;
/**
* Copy the iterable into an Iterator.
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable

View File

@ -17,7 +17,7 @@ use Generator;
* Iter\values([17 => 1, 42 => 2, -2 => 100])
* => Iter(0 => 1, 1 => 42, 2 => 100)
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> $iterable Iterable to get values from

View File

@ -22,7 +22,7 @@ use Generator;
* Arr(2, 2, 2) => Arr(3, 6, 9)
* )
*
* @psalm-template Tk as array-key
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param iterable<Tk, Tv> ...$iterables