@@ -353,51 +353,51 @@ public static function reverse(string $s): string
353353
354354 /**
355355 * Returns part of $haystack before $nth occurence of $needle (negative value means searching from the end).
356- * @return string|FALSE returns FALSE if the needle was not found
356+ * @return string|NULL returns NULL if the needle was not found
357357 */
358358 public static function before (string $ haystack , string $ needle , int $ nth = 1 )
359359 {
360360 $ pos = self ::pos ($ haystack , $ needle , $ nth );
361- return $ pos === FALSE
362- ? FALSE
361+ return $ pos === NULL
362+ ? NULL
363363 : substr ($ haystack , 0 , $ pos );
364364 }
365365
366366
367367 /**
368368 * Returns part of $haystack after $nth occurence of $needle (negative value means searching from the end).
369- * @return string|FALSE returns FALSE if the needle was not found
369+ * @return string|NULL returns NULL if the needle was not found
370370 */
371371 public static function after (string $ haystack , string $ needle , int $ nth = 1 )
372372 {
373373 $ pos = self ::pos ($ haystack , $ needle , $ nth );
374- return $ pos === FALSE
375- ? FALSE
374+ return $ pos === NULL
375+ ? NULL
376376 : substr ($ haystack , $ pos + strlen ($ needle ));
377377 }
378378
379379
380380 /**
381381 * Returns position of $nth occurence of $needle in $haystack (negative value means searching from the end).
382- * @return int|FALSE offset in characters or FALSE if the needle was not found
382+ * @return int|NULL offset in characters or NULL if the needle was not found
383383 */
384384 public static function indexOf (string $ haystack , string $ needle , int $ nth = 1 )
385385 {
386386 $ pos = self ::pos ($ haystack , $ needle , $ nth );
387- return $ pos === FALSE
388- ? FALSE
387+ return $ pos === NULL
388+ ? NULL
389389 : self ::length (substr ($ haystack , 0 , $ pos ));
390390 }
391391
392392
393393 /**
394394 * Returns position of $nth occurence of $needle in $haystack.
395- * @return int|FALSE offset in bytes or FALSE if the needle was not found
395+ * @return int|NULL offset in bytes or NULL if the needle was not found
396396 */
397397 private static function pos (string $ haystack , string $ needle , int $ nth = 1 )
398398 {
399399 if (!$ nth ) {
400- return FALSE ;
400+ return NULL ;
401401 } elseif ($ nth > 0 ) {
402402 if (strlen ($ needle ) === 0 ) {
403403 return 0 ;
@@ -416,7 +416,7 @@ private static function pos(string $haystack, string $needle, int $nth = 1)
416416 $ pos --;
417417 }
418418 }
419- return $ pos ;
419+ return $ pos === FALSE ? NULL : $ pos ;
420420 }
421421
422422
0 commit comments