-
Notifications
You must be signed in to change notification settings - Fork 428
/
array-filter.php
37 lines (30 loc) · 1005 Bytes
/
array-filter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace ArrayFilter;
use function PHPStan\Testing\assertType;
function withoutAnyArgs(): void
{
$filtered1 = array_filter();
assertType('array', $filtered1);
}
/**
* @param $var1 $mixed
*/
function withMixedInsteadOfArray($var1): void
{
$filtered1 = array_filter($var1);
assertType('(array|null)', $filtered1);
}
/**
* @param array<string, bool|float|int|string> $map1
* @param array<string, bool|float|int|string> $map2
* @param array<string, bool|float|int|string> $map3
*/
function withoutCallback(array $map1, array $map2, array $map3): void
{
$filtered1 = array_filter($map1);
assertType('array<string, float|int<min, -1>|int<1, max>|non-empty-string|true>', $filtered1);
$filtered2 = array_filter($map2, null, ARRAY_FILTER_USE_KEY);
assertType('array<string, bool|float|int|string>', $filtered2); // not supported yet
$filtered3 = array_filter($map3, null, ARRAY_FILTER_USE_BOTH);
assertType('array<string, bool|float|int|string>', $filtered3); // not supported yet
}