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
116 lines (103 loc) · 2.68 KB
/
bug-6799.php
File metadata and controls
116 lines (103 loc) · 2.68 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php declare(strict_types = 1);
namespace Bug6799;
use function PHPStan\Testing\assertType;
/**
* @param array<int> $items
*/
function functionProcessInts(array &$items): void
{
$items = [1, 2];
}
/**
* @param array<string> $items
*/
function functionProcessStrings(array &$items): void
{
$items = ['a', 'b'];
}
class HelloWorld
{
/**
* @param string[] $where
* @param string $sqlTableName
* @param mixed[] $filter
* @param string $value
*/
protected function listingAddWhereFilterAtableDefault(array &$where, string $sqlTableName, array $filter, string $value): void
{
if ($value != "" && !empty($filter) && !empty($filter['sql']) && is_string($filter['sql'])) {
$where[] = "`" . $sqlTableName . "`.`" . (string)$filter['sql'] . "` = '" . $value . "'";
}
}
/**
* @param string[] $filterValues
* @param string[] $where
* @param string[] $tables
* @param mixed[] $filters
*/
protected function listingAddWhereFilterAtable(array $filterValues, array &$where, array &$tables, array $filters): void
{
if (!empty($filterValues) && !empty($filters)) {
$whereFilter = array();
foreach ($filterValues as $type => $value) {
call_user_func_array(array($this, 'listingAddWhereFilterAtableDefault'), array(&$whereFilter, 'xxxx', $filters[$type], $value));
}
assertType('array<string>', $whereFilter);
}
}
/**
* @param array<mixed> $items
* @param-out list<int> $items
*/
protected function processWithParamOut(array &$items): void
{
$items = [1, 2, 3];
}
protected function testParamOut(): void
{
$items = [];
call_user_func_array([$this, 'processWithParamOut'], [&$items]);
assertType('list<int>', $items);
}
/**
* @param array<int> $items
*/
protected function processInts(array &$items): void
{
$items = [1, 2];
}
/**
* @param array<string> $items
*/
protected function processStrings(array &$items): void
{
$items = ['a', 'b'];
}
/**
* @param 'Bug6799\functionProcessInts'|'Bug6799\functionProcessStrings' $function
*/
protected function testUnionStringCallbacks(string $function): void
{
$items = [];
call_user_func_array($function, [&$items]);
assertType('array<int|string>', $items);
}
/**
* @param array{$this, 'processInts'}|array{$this, 'processStrings'} $callback
*/
protected function testUnionArrayCallbacks(array $callback): void
{
$items = [];
call_user_func_array($callback, [&$items]);
assertType('array<int|string>', $items);
}
/**
* @param 'Bug6799\functionProcessInts'|array{$this, 'processStrings'} $callback
*/
protected function testMixedUnionCallback($callback): void
{
$items = [];
call_user_func_array($callback, [&$items]);
assertType('array<int|string>', $items);
}
}