forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall-user-func_array.php
More file actions
55 lines (45 loc) · 1012 Bytes
/
call-user-func_array.php
File metadata and controls
55 lines (45 loc) · 1012 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace CallUserFuncArray;
use function PHPStan\Testing\assertType;
/**
* @template T
* @param T $t
* @return T
*/
function generic($t) {
return $t;
}
function fun(): int
{
return 3;
}
function fun3($i, $x, $y): int
{
return 3;
}
class c {
static function m(): string
{
return 'hello';
}
}
class Foo {
function proxy() {
$params = [
'CallUserFunc\generic',
[123, 456],
];
assertType('mixed', call_user_func_array(...$params));
}
/**
* @param string[] $strings
*/
function doFunc($strings) {
assertType('true', call_user_func_array('CallUserFunc\generic', [true]));
assertType('\'hello\'', call_user_func_array('CallUserFunc\generic', ['hello']));
assertType('array<string>', call_user_func_array('CallUserFunc\generic', [$strings]));
assertType('int', call_user_func_array('CallUserFunc\fun', []));
assertType('int', call_user_func_array('CallUserFunc\fun3', [1 ,2 ,3]));
assertType('string', call_user_func_array(['CallUserFunc\c', 'm'], []));
}
}