@@ -134,6 +134,29 @@ public function doEmpty2(string $s): void
134134 }
135135 }
136136
137+ /**
138+ * @param non-empty-string $nonEmpty
139+ * @param positive-int $positiveInt
140+ * @param 1|2|3 $postiveRange
141+ * @param -1|-2|-3 $negativeRange
142+ */
143+ public function doSubstr (string $ s , $ nonEmpty , $ positiveInt , $ postiveRange , $ negativeRange ): void
144+ {
145+ assertType ('string ' , substr ($ s , 5 ));
146+
147+ assertType ('string ' , substr ($ s , -5 ));
148+ assertType ('non-empty-string ' , substr ($ nonEmpty , -5 ));
149+ assertType ('non-empty-string ' , substr ($ nonEmpty , $ negativeRange ));
150+
151+ assertType ('string ' , substr ($ s , 0 , 5 ));
152+ assertType ('non-empty-string ' , substr ($ nonEmpty , 0 , 5 ));
153+ assertType ('non-empty-string ' , substr ($ nonEmpty , 0 , $ postiveRange ));
154+
155+ assertType ('string ' , substr ($ nonEmpty , 0 , -5 ));
156+
157+ assertType ('string ' , substr ($ s , 0 , $ positiveInt ));
158+ assertType ('non-empty-string ' , substr ($ nonEmpty , 0 , $ positiveInt ));
159+ }
137160}
138161
139162class ImplodingStrings
@@ -186,15 +209,16 @@ public function doFoo4(string $s, array $nonEmptyArrayWithNonEmptyStrings): void
186209 public function sayHello (): void
187210 {
188211 // coming from issue #5291
189- $ s = array (1 ,2 );
212+ $ s = array (1 , 2 );
190213
191214 assertType ('non-empty-string ' , implode ("a " , $ s ));
192215 }
193216
194217 /**
195218 * @param non-empty-string $glue
196219 */
197- public function nonE ($ glue , array $ a ) {
220+ public function nonE ($ glue , array $ a )
221+ {
198222 // coming from issue #5291
199223 if (empty ($ a )) {
200224 return "xyz " ;
@@ -206,15 +230,16 @@ public function nonE($glue, array $a) {
206230 public function sayHello2 (): void
207231 {
208232 // coming from issue #5291
209- $ s = array (1 ,2 );
233+ $ s = array (1 , 2 );
210234
211235 assertType ('non-empty-string ' , join ("a " , $ s ));
212236 }
213237
214238 /**
215239 * @param non-empty-string $glue
216240 */
217- public function nonE2 ($ glue , array $ a ) {
241+ public function nonE2 ($ glue , array $ a )
242+ {
218243 // coming from issue #5291
219244 if (empty ($ a )) {
220245 return "xyz " ;
@@ -228,7 +253,8 @@ public function nonE2($glue, array $a) {
228253class LiteralString
229254{
230255
231- function x (string $ tableName , string $ original ): void {
256+ function x (string $ tableName , string $ original ): void
257+ {
232258 assertType ('non-empty-string ' , "from ` $ tableName` " );
233259 }
234260
@@ -297,7 +323,7 @@ public function doFoo(string $s, string $nonEmpty, int $i)
297323 assertType ('non-empty-string ' , htmlspecialchars ($ nonEmpty ));
298324 assertType ('string ' , htmlentities ($ s ));
299325 assertType ('non-empty-string ' , htmlentities ($ nonEmpty ));
300-
326+
301327 assertType ('string ' , urlencode ($ s ));
302328 assertType ('non-empty-string ' , urlencode ($ nonEmpty ));
303329 assertType ('string ' , urldecode ($ s ));
0 commit comments