Skip to content

Commit b31eb35

Browse files
committed
Add array_chunk tests for array offsets
1 parent 61afdaa commit b31eb35

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/PHPStan/Analyser/nsrt/array-chunk.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,18 @@ function testLimits(array $arr, int $oneToFour, int $tooBig) {
7474
assertType('non-empty-list<non-empty-list<0|1|2|3>>', array_chunk($arr, $tooBig));
7575
}
7676

77+
public function offsets(array $arr): void
78+
{
79+
if (array_key_exists('foo', $arr)) {
80+
assertType('non-empty-list<non-empty-list<mixed>>', array_chunk($arr, 2));
81+
assertType('non-empty-list<non-empty-array>', array_chunk($arr, 2, true));
82+
}
83+
84+
if (array_key_exists('foo', $arr) && $arr['foo'] === 'bar') {
85+
assertType('non-empty-list<non-empty-list<mixed>>', array_chunk($arr, 2));
86+
assertType('non-empty-list<non-empty-array>', array_chunk($arr, 2, true));
87+
}
88+
89+
}
7790

7891
}

0 commit comments

Comments
 (0)