forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-14353.php
More file actions
68 lines (54 loc) · 1.03 KB
/
Copy pathbug-14353.php
File metadata and controls
68 lines (54 loc) · 1.03 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
<?php
namespace Bug14353;
/** @return array<int> */
function get(): array
{
return [1];
}
class Test
{
public function test(): void
{
$reports = [];
foreach (get() as $report) {
$reports[$report] = $report;
}
if (isset($this->data)) {
foreach ($reports as $report_id => $report) {
$report_ids[$report_id] = 1;
}
} else {
foreach ($reports as $report_id => $report) {
$report_ids[$report_id] = 1;
}
}
if (isset($report_ids)) {
var_dump($report_ids);
foreach ($reports as $report) {}
var_dump($report_ids);
}
}
public function testWithIfBranch(): void
{
$reports = [];
foreach (get() as $report) {
$reports[$report] = $report;
}
if (isset($this->data)) {
foreach ($reports as $report_id => $report) {
$report_ids[$report_id] = 1;
}
} else {
foreach ($reports as $report_id => $report) {
$report_ids[$report_id] = 1;
}
}
if (isset($report_ids)) {
var_dump($report_ids);
if ($reports === []) {
echo 'empty';
}
var_dump($report_ids);
}
}
}