Skip to content

Commit a7b5c77

Browse files
committed
test invers
1 parent c4e7c87 commit a7b5c77

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/PHPStan/Analyser/nsrt/bug-12163.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Test
88
{
9-
public function iterateRowColumnIndices(int $rows, int $columns): void
9+
public function iterateRowColumnIndicesIncrementing(int $rows, int $columns): void
1010
{
1111
if ($rows < 1 || $columns < 1) return;
1212
$size = $rows * $columns;
@@ -25,3 +25,25 @@ public function iterateRowColumnIndices(int $rows, int $columns): void
2525
}
2626
}
2727
}
28+
29+
class Test2
30+
{
31+
public function iterateRowColumnIndicesDecrementing(int $rows, int $columns): void
32+
{
33+
if ($rows < 1 || $columns < 1) return;
34+
$size = $rows * $columns;
35+
36+
$rowIndex = 0;
37+
$columnIndex = 0;
38+
for ($i = 0; $i < $size; $i++) {
39+
assertType('0', $rowIndex);
40+
assertType('int<min, 0>', $columnIndex);
41+
if ($columnIndex < $columns) {
42+
$columnIndex--;
43+
} else {
44+
$columnIndex = 0;
45+
$rowIndex++;
46+
}
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)