Skip to content

Commit 06ab320

Browse files
schlndhondrejmirtes
authored andcommitted
add generic types for array_values
1 parent cb8f910 commit 06ab320

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

stubs/arrayFunctions.stub

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ function array_reduce(
1616
$three = null
1717
) {}
1818

19+
/**
20+
* @template T of mixed
21+
*
22+
* @param array<T> $array
23+
* @return ($array is non-empty-array ? non-empty-list<T> : list<T>)
24+
*/
25+
function array_values(array $array): array {}
26+
1927
/**
2028
* @template TKey as (int|string)
2129
* @template T

tests/PHPStan/Analyser/nsrt/array_values.php

+8
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,12 @@ public function constantArrayType(): void
3737
);
3838
assertType("array{0?: 'a'|'b'|'c', 1?: 'b'|'c', 2?: 'c'}", array_values($numbers));
3939
}
40+
41+
/**
42+
* @param array<string, non-empty-array<string, int>> $a
43+
*/
44+
public function arrayMap(array $a): void
45+
{
46+
assertType('array<string, non-empty-list<int>>', array_map(array_values(...), $a));
47+
}
4048
}

0 commit comments

Comments
 (0)