forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-10089.php
More file actions
44 lines (31 loc) · 768 Bytes
/
bug-10089.php
File metadata and controls
44 lines (31 loc) · 768 Bytes
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
<?php
namespace Bug10089;
use function PHPStan\Testing\assertType;
class Test
{
protected function create_matrix(int $size): array
{
$size = min(8, $size);
$matrix = [];
for ($i = 0; $i < $size; $i++) {
$matrix[] = array_fill(0, $size, 0);
}
// array<int<0, max>, non-empty-array<int, 0>>
assertType('list<non-empty-list<0>>', $matrix);
$matrix[$size - 1][8] = 3;
// non-empty-array<int, non-empty-array<int, 0|3>&hasOffsetValue(8, 3)>
assertType('non-empty-array<int, non-empty-array<int<0, max>, 0|3>>', $matrix);
for ($i = 0; $i <= $size; $i++) {
if ($matrix[$i][8] === 0) {
// ...
}
if ($matrix[8][$i] === 0) {
// ...
}
if ($matrix[$size - 1 - $i][8] === 0) {
// ...
}
}
return $matrix;
}
}