Skip to content

Commit 674fdb8

Browse files
committed
add regression test
1 parent 9c7a3e4 commit 674fdb8

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Bug10089;
4+
5+
6+
use function PHPStan\Testing\assertType;
7+
8+
class Test
9+
{
10+
11+
protected function create_matrix(int $size): array
12+
{
13+
$size = min(8, $size);
14+
$matrix = [];
15+
for ($i = 0; $i < $size; $i++) {
16+
$matrix[] = array_fill(0, $size, 0);
17+
}
18+
19+
// array<int<0, max>, non-empty-array<int, 0>>
20+
assertType('list<non-empty-list<0>>', $matrix);
21+
22+
$matrix[$size - 1][8] = 3;
23+
24+
// non-empty-array<int, non-empty-array<int, 0|3>&hasOffsetValue(8, 3)>
25+
assertType('non-empty-list<non-empty-array<int<0, max>, 0|3>>', $matrix);
26+
27+
for ($i = 0; $i <= $size; $i++) {
28+
if ($matrix[$i][8] === 0) {
29+
// ...
30+
}
31+
if ($matrix[8][$i] === 0) {
32+
// ...
33+
}
34+
if ($matrix[$size - 1 - $i][8] === 0) {
35+
// ...
36+
}
37+
}
38+
39+
return $matrix;
40+
}
41+
42+
}
43+
44+

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,11 @@ public function testBug13282(): void
10461046
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-13282.php'], []);
10471047
}
10481048

1049+
public function testBug10089(): void
1050+
{
1051+
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-10089.php'], []);
1052+
}
1053+
10491054
public function testBug11609(): void
10501055
{
10511056
$this->analyse([__DIR__ . '/data/bug-11609.php'], [

0 commit comments

Comments
 (0)