1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

add some more stubs for array functions (#4271)

* add some more stubs for array functions

* add function brackets to stubs

* add parameter names

* remove redundant brackets

* remove stubs already defined in return type providers
This commit is contained in:
Marco Perone 2020-10-06 15:13:19 +02:00 committed by Daniil Gentili
parent 580d3e2b61
commit 696e353c8b
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -49,6 +49,25 @@ function array_intersect_key(array $arr, array $arr2, array ...$arr3)
* @psalm-template TValue
*
* @param array<TKey, TValue> $arr
* @param array $arr2
* @param array ...$arr3
* @param callable(TKey): int $keyCompareFunc
*
* @return array<TKey, TValue>
*
* @psalm-pure
*/
function array_intersect_ukey(array $arr, array $arr2, array ...$arr3, callable $keyCompareFunc): array
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
*
* @param array<TKey, TValue> $arr
* @param array $arr2
* @param array ...$arr3
*
* @return array<TKey, TValue>
* @psalm-pure
@ -57,6 +76,23 @@ function array_intersect_assoc(array $arr, array $arr2, array ...$arr3)
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
*
* @param array<TKey, TValue> $arr
* @param array $arr2
* @param array ...$arr3
* @param callable(TKey): int $keyCompareFunc
*
* @return array<TKey, TValue>
*
* @psalm-pure
*/
function array_intersect_uassoc(array $arr, array $arr2, array ...$arr3, callable $keyCompareFunc): array {}
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
@ -102,6 +138,22 @@ function array_diff_key(array $arr, array $arr2, array ...$arr3)
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
*
* @param array<TKey, TValue> $arr
* @param array $arr2
* @param array ...$arr3
* @param callable(TKey, TKey): int $keyCompareFunc
*
* @return array<TKey, TValue>
* @psalm-pure
*/
function array_diff_ukey(array $arr, array $arr2, array ...$arr3, callable $keyCompareFunc): array {}
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
@ -117,6 +169,20 @@ function array_diff_assoc(array $arr, array $arr2, array ...$arr3)
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
*
* @param array<TKey, TValue> $arr
* @param array $arr2
* @param array ...$arr3
* @param callable(TKey, TKey): int $keyCompareFunc
*
* @return array<TKey, TValue>
* @psalm-pure
*/
function array_diff_uassoc(array $arr, array $arr2, array ... $arr3, callable $keyCompareFunc): array {}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
@ -550,6 +616,20 @@ function explode(string $delimiter, string $string, int $limit = -1) : array {}
*/
function array_sum(array $input) {}
/**
* @param array $input
*
* @return (
* $input is array<int>
* ? int
* : ($input is array<float>
* ? float
* : float|int
* )
* )
*/
function array_product(array $input) {}
/**
* @psalm-pure
*
@ -736,3 +816,14 @@ function str_getcsv(string $input, string $delimiter = ',', string $enclosure =
* @return ($min is positive-int ? positive-int : int)
*/
function random_int(int $min, int $max): int {}
/**
* @template TKey as array-key
*
* @param array<mixed, TKey> $array
*
* @return array<TKey, positive-int>
*
* @psalm-pure
*/
function array_count_values(array $array): array {}