Skip to content

Commit cb6e0ed

Browse files
committed
test limits
1 parent 6d4ac74 commit cb6e0ed

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/PHPStan/Analyser/nsrt/bug-13747.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,27 @@ public function doBar($list): void
5151
assertType('1', count($list));
5252
}
5353
}
54+
55+
/** @param list<int> $list */
56+
public function checkLimit($list): void
57+
{
58+
if (count($list) === 0) {
59+
return;
60+
}
61+
62+
if (count($list) > 9) {
63+
assertType('non-empty-list<int>&hasOffsetValue(1, int)&hasOffsetValue(2, int)&hasOffsetValue(3, int)&hasOffsetValue(4, int)&hasOffsetValue(5, int)&hasOffsetValue(6, int)&hasOffsetValue(7, int)&hasOffsetValue(8, int)&hasOffsetValue(9, int)', $list);
64+
assertType('int<10, max>', count($list));
65+
} else {
66+
assertType('non-empty-list<int>', $list);
67+
}
68+
69+
if (count($list) > 10) {
70+
assertType('non-empty-list<int>&hasOffsetValue(1, int)&hasOffsetValue(2, int)&hasOffsetValue(3, int)&hasOffsetValue(4, int)&hasOffsetValue(5, int)&hasOffsetValue(6, int)&hasOffsetValue(7, int)&hasOffsetValue(8, int)&hasOffsetValue(9, int)', $list);
71+
assertType('int<11, max>', count($list));
72+
} else {
73+
assertType('non-empty-list<int>', $list);
74+
}
75+
76+
}
5477
}

0 commit comments

Comments
 (0)