Skip to content

Commit edb694c

Browse files
committed
Fixing notices from phpstan
1 parent 8d9bdb7 commit edb694c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/StringHelper.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function increment($string, $style = 'default', $n = 0)
7474

7575
// Check if we are incrementing an existing pattern, or appending a new one.
7676
if (preg_match($rxSearch, $string, $matches)) {
77-
$n = empty($n) ? ($matches[1] + 1) : $n;
77+
$n = empty($n) ? (1 + (int) $matches[1]) : $n;
7878
$string = preg_replace($rxReplace, sprintf($oldFormat, $n), $string);
7979
} else {
8080
$n = empty($n) ? 2 : $n;
@@ -375,7 +375,7 @@ public static function strcasecmp($str1, $str2, $locale = false)
375375
}
376376

377377
// Get current locale
378-
$locale0 = setlocale(LC_COLLATE, 0);
378+
$locale0 = setlocale(LC_COLLATE, null);
379379

380380
if (!$locale = setlocale(LC_COLLATE, $locale)) {
381381
$locale = $locale0;
@@ -421,7 +421,7 @@ public static function strcmp($str1, $str2, $locale = false)
421421
{
422422
if ($locale) {
423423
// Get current locale
424-
$locale0 = setlocale(LC_COLLATE, 0);
424+
$locale0 = setlocale(LC_COLLATE, null);
425425

426426
if (!$locale = setlocale(LC_COLLATE, $locale)) {
427427
$locale = $locale0;
@@ -462,9 +462,9 @@ public static function strcmp($str1, $str2, $locale = false)
462462
* @link https://www.php.net/strcspn
463463
* @since 1.3.0
464464
*/
465-
public static function strcspn($str, $mask, $start = null, $length = null)
465+
public static function strcspn(string $str, string $mask, $start = null, $length = null)
466466
{
467-
if (empty($mask) || strlen($mask) == 0) {
467+
if (strlen($mask) == 0) {
468468
return 0;
469469
}
470470

@@ -535,15 +535,15 @@ public static function strrev($str)
535535
* @link https://www.php.net/strspn
536536
* @since 1.3.0
537537
*/
538-
public static function strspn($str, $mask, $start = null, $length = null)
538+
public static function strspn(string $str, string $mask, ?int $start = null, ?int $length = null)
539539
{
540540
$mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\${1}', $mask);
541541

542-
if (is_int($start) && is_int($length)) {
542+
if ($start && $length) {
543543
$str = mb_substr($str, $start, $length);
544-
} elseif (is_int($start) && !is_int($length)) {
544+
} elseif ($start) {
545545
$str = mb_substr($str, $start);
546-
} elseif (!is_int($start) && is_int($length)) {
546+
} elseif ($length) {
547547
trigger_error('\Joomla\String\StringHelper::strspn(): Passing null to parameter #3 ($start) of type int is deprecated', E_USER_DEPRECATED);
548548
$str = mb_substr($str, 0, $length);
549549
}

0 commit comments

Comments
 (0)