Skip to content

Commit d52ed95

Browse files
committed
test optional keys
1 parent 6d2574e commit d52ed95

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/PHPStan/Analyser/nsrt/count-recursive.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ public function countConstantArray(array $anotherArray): void {
121121
assertType('4', count($arr, COUNT_NORMAL));
122122
assertType('int<1, max>', count($arr, COUNT_RECURSIVE)); // could be int<4, max>
123123

124+
if (rand(0,1)) {
125+
$arr[] = 10;
126+
}
127+
assertType('array{0: 1, 1: 2, 2: 3, 3: array, 4?: 10}', $arr);
128+
assertType('int<4, 5>', count($arr));
129+
assertType('int<4, 5>', count($arr, COUNT_NORMAL));
130+
assertType('int<1, max>', count($arr, COUNT_RECURSIVE)); // could be int<4, max>
131+
124132
$arr = [1, 2, 3] + $anotherArray;
125133
assertType('non-empty-array&hasOffsetValue(0, 1)&hasOffsetValue(1, 2)&hasOffsetValue(2, 3)', $arr);
126134
assertType('int<3, max>', count($arr));

0 commit comments

Comments
 (0)