File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,35 @@ public function sayHello($list): void
2020 assertType ('non-empty-list<int> ' , $ list );
2121 }
2222 }
23+
24+ /** @param list<int> $list */
25+ public function doFoo ($ list ): void
26+ {
27+ if (count ($ list ) === 0 ) {
28+ return ;
29+ }
30+
31+ if (count ($ list ) >= 2 ) {
32+ assertType ('non-empty-list<int>&hasOffsetValue(1, int) ' , $ list );
33+ assertType ('int<2, max> ' , count ($ list ));
34+ } else {
35+ assertType ('non-empty-list<int> ' , $ list );
36+ }
37+ }
38+
39+ /** @param list<int> $list */
40+ public function doBar ($ list ): void
41+ {
42+ if (count ($ list ) === 0 ) {
43+ return ;
44+ }
45+
46+ if (2 <= count ($ list )) {
47+ assertType ('non-empty-list<int>&hasOffsetValue(1, int) ' , $ list );
48+ assertType ('int<2, max> ' , count ($ list ));
49+ } else {
50+ assertType ('non-empty-list<int> ' , $ list );
51+ assertType ('1 ' , count ($ list ));
52+ }
53+ }
2354}
You can’t perform that action at this time.
0 commit comments