@@ -69,6 +69,31 @@ public function anyIntLessThanCount(array $array, int $index): int
6969 return 0 ;
7070 }
7171
72+ /**
73+ * @param list<int> $array
74+ * @param int<0, max> $index
75+ */
76+ public function positiveIntOnNormalCountMode (array $ array , int $ index ): int
77+ {
78+ if ($ index < count ($ array , COUNT_NORMAL )) {
79+ return $ array [$ index ]; // should not error
80+ }
81+
82+ return 0 ;
83+ }
84+
85+ /**
86+ * @param list<int> $array
87+ */
88+ public function anyIntOnUnknownCountMode (array $ array , int $ index , $ countMode ): int
89+ {
90+ if ($ index < count ($ array , $ countMode )) {
91+ return $ array [$ index ]; // SHOULD still report - could be negative
92+ }
93+
94+ return 0 ;
95+ }
96+
7297 public function anyIntOnRecursiveCount (array $ array , int $ index ): int
7398 {
7499 if ($ index < count ($ array , COUNT_RECURSIVE )) {
@@ -77,4 +102,30 @@ public function anyIntOnRecursiveCount(array $array, int $index): int
77102
78103 return 0 ;
79104 }
105+
106+ /**
107+ * @param list<int> $array
108+ * @param 3|6|10 $index
109+ */
110+ public function constantPositiveIntLessThanCount (array $ array , int $ index ): int
111+ {
112+ if ($ index < count ($ array )) {
113+ return $ array [$ index ]; // should not report
114+ }
115+
116+ return 0 ;
117+ }
118+
119+ /**
120+ * @param list<int> $array
121+ * @param -1|3|6|10 $index
122+ */
123+ public function constantMaybeNegativeIntLessThanCount (array $ array , int $ index ): int
124+ {
125+ if ($ index < count ($ array )) {
126+ return $ array [$ index ]; // SHOULD still report - could be negative
127+ }
128+
129+ return 0 ;
130+ }
80131}
0 commit comments