Skip to content

Commit fcd1a6f

Browse files
committed
test recursive count
1 parent 1e88894 commit fcd1a6f

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
@@ -1168,6 +1168,10 @@ public function testBug13770(): void
11681168
'Offset int might not exist on list<int>.',
11691169
66,
11701170
],
1171+
[
1172+
'Offset int might not exist on list<int>.',
1173+
75,
1174+
],
11711175
]);
11721176
}
11731177

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)