forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-6799.php
More file actions
78 lines (68 loc) · 1.61 KB
/
bug-6799.php
File metadata and controls
78 lines (68 loc) · 1.61 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php declare(strict_types = 1);
namespace Bug6799;
use function PHPStan\Testing\assertType;
class HelloWorld
{
/**
* @param string[] $where
* @param mixed[] $filter
*/
protected function addFilter(array &$where, array $filter, string $value): void
{
if ($value != "" && !empty($filter) && !empty($filter['sql']) && is_string($filter['sql'])) {
$where[] = (string)$filter['sql'] . " = '" . $value . "'";
}
}
/**
* @param string[] $filterValues
* @param mixed[] $filters
*/
protected function test(array $filterValues, array $filters): void
{
if (!empty($filterValues) && !empty($filters)) {
$whereFilter = array();
foreach ($filterValues as $type => $value) {
call_user_func_array(array($this, 'addFilter'), array(&$whereFilter, $filters[$type], $value));
}
assertType('array<string>', $whereFilter);
}
}
}
function testSimple(): void
{
$arr = [];
some_function(1, [&$arr, 'foo']);
assertType('mixed', $arr);
}
function testDirectFunction(): void
{
$result = [];
call_user_func_array('Bug6799\modify_by_ref', [&$result, 'value']);
assertType('array<string>', $result);
}
/** @param callable $callback */
function testUnresolvableCallback($callback): void
{
$arr = [];
call_user_func_array($callback, [&$arr, 'foo']);
assertType('mixed', $arr);
}
function testCallbackNotByRef(): void
{
$arr = [];
call_user_func_array('Bug6799\some_function', [1, [&$arr, 'foo']]);
assertType('mixed', $arr);
}
/**
* @param string[] $arr
*/
function modify_by_ref(array &$arr, string $value): void
{
$arr[] = $value;
}
/**
* @param mixed $x
*/
function some_function(int $a, $x): void
{
}