-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathbug-6799.php
More file actions
87 lines (72 loc) · 1.83 KB
/
bug-6799.php
File metadata and controls
87 lines (72 loc) · 1.83 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
<?php declare(strict_types = 1);
namespace Bug6799;
use function PHPStan\Testing\assertType;
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('mixed', $whereFilter);
if (count($whereFilter) > 0) {
$where[] = "(" . implode(" AND ", $whereFilter) . ")";
}
}
}
}
/**
* @param mixed $foo
*/
function foo($foo): void {}
function testByRefInArray(): void
{
$a = [];
assertType('array{}', $a);
$b = [&$a];
assertType('array{}', $a);
foo($b);
assertType('array{}', $a);
}
function testByRefInArrayWithKey(): void
{
$a = 'hello';
assertType("'hello'", $a);
$b = ['key' => &$a];
assertType("'hello'", $a);
$b['key'] = 42;
assertType("'hello'", $a);
}
function testMultipleByRefInArray(): void
{
$a = 1;
$c = 'test';
$b = [&$a, 'normal', &$c];
assertType('1', $a);
assertType("'test'", $c);
$b[0] = 2;
$b[1] = 'foo';
$b[2] = 'bar';
assertType('1', $a);
assertType("'test'", $c);
}