-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathbug-10349.php
More file actions
101 lines (90 loc) · 2.24 KB
/
bug-10349.php
File metadata and controls
101 lines (90 loc) · 2.24 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
<?php declare(strict_types = 1);
namespace Bug10349;
class Foo
{
/**
* @param array<string, array<string, bool|float|int|string>> $expected
*/
public function issue1A(array $expected, int $ptr): void
{
foreach ($expected as $key => $param) {
if ($param['number-1'] !== false) {
// This gets flagged
$expected[$key]['number-1'] += $ptr;
}
if ($param['number-2'] !== false) {
// This should also get flagged but doesn't
$expected[$key]['number-2'] += $ptr;
}
}
}
/**
* @param array<string, array<string, bool|float|int|string>> $expected
*/
public function issue1B(array $expected, int $ptr): void
{
foreach ($expected as $key => $param) {
if (is_int($expected[$key]['number-1'])) {
$expected[$key]['number-1'] += $ptr;
}
// Even after fixing the first, the second one still doesn't get flagged
if ($param['number-2'] !== false) {
$expected[$key]['number-2'] += $ptr;
}
}
}
/**
* @param array<string, array<string, bool|float|int|string>> $expected
*/
public function multipleOpsNoLoop(array $expected, int $ptr, string $key): void
{
$expected[$key]['number-1'] += $ptr;
// After the first += corrupts the array type, this should still be flagged
$expected[$key]['number-2'] += $ptr;
}
/**
* @param array<string, bool|float|int|string> $arr
*/
public function simpleArray(array $arr, int $ptr): void
{
$arr['a'] += $ptr;
// After the first += corrupts the array type, this should still be flagged
$arr['b'] += $ptr;
}
/**
* @param array<string, bool|float|int|string> $arr
*/
public function otherAssignOps(array $arr, int $ptr): void
{
$arr['a'] -= $ptr;
$arr['b'] -= $ptr;
$arr['c'] *= $ptr;
$arr['d'] *= $ptr;
}
/**
* @param array<string, array<int>|int> $arr
*/
public function concatAssignOps(array $arr): void
{
$arr['a'] .= 'foo';
$arr['b'] .= 'foo';
}
/**
* @param array<string, bool|float|int|string> $arr
*/
public function divAndModAssignOps(array $arr, int $ptr): void
{
$arr['a'] /= $ptr;
$arr['b'] /= $ptr;
$arr['c'] %= $ptr;
$arr['d'] %= $ptr;
}
/**
* @param array<string, bool|float|int|string> $arr
*/
public function bitwiseAssignOps(array $arr, int $ptr): void
{
$arr['a'] <<= $ptr;
$arr['b'] <<= $ptr;
}
}