Skip to content

Commit 193a4f6

Browse files
committed
another test
1 parent 2aed77d commit 193a4f6

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,10 @@ public function testBug13770(): void
11941194
'Offset int<0, max> might not exist on array.',
11951195
177,
11961196
],
1197+
[
1198+
'Offset -5|int<0, max> might not exist on list<int>.',
1199+
190,
1200+
],
11971201
]);
11981202
}
11991203

tests/PHPStan/Rules/Arrays/data/bug-13770.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,17 @@ public function errorsBecauseNotList(array $array, int $index): int
179179

180180
return 0;
181181
}
182+
183+
/**
184+
* @param list<int> $array
185+
* @param -5|0|positive-int $index
186+
*/
187+
public function errorsBecauseMaybeTooSmall(array $array, int $index): int
188+
{
189+
if ($index <= count($array) - 5) {
190+
return $array[$index];
191+
}
192+
193+
return 0;
194+
}
182195
}

0 commit comments

Comments
 (0)