Skip to content

Commit 07dcbc8

Browse files
committed
test recursive count
1 parent a0bff63 commit 07dcbc8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ public function testBug13770(): void
11741174
'Offset int might not exist on list<int>.',
11751175
66,
11761176
],
1177+
[
1178+
'Offset int might not exist on list<int>.',
1179+
75,
1180+
],
11771181
]);
11781182
}
11791183

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ public function anyIntLessThanCount(array $array, int $index): int
6868

6969
return 0;
7070
}
71+
72+
public function anyIntOnRecursiveCount(array $array, int $index): int
73+
{
74+
if ($index < count($array, COUNT_RECURSIVE)) {
75+
return $array[$index]; // SHOULD still report - could be negative
76+
}
77+
78+
return 0;
79+
}
7180
}

0 commit comments

Comments
 (0)