Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Tests/StringHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ public static function seedCompliantStrings(): array
["\xFBa", false],
["\xFDa", false],
["foo\xF7bar", false],
'five octet sequence' => ["\xF8\x88\x80\x80\x80", false],
'six octet sequence' => ["\xFC\x84\x80\x80\x80\x80", false],
['george Мога Ž Ψυχοφθόρα ฉันกินกระจกได้ 我能吞下玻璃而不伤身体 ', true],
["\xFF ABC", false],
["0xfffd ABC", true],
Expand Down
6 changes: 2 additions & 4 deletions src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
*/
public static function str_pad($input, $length, $padStr = ' ', $type = STR_PAD_RIGHT)
{
return mb_str_pad($input, $length, $padStr, $type);

Check failure on line 333 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_str_pad not found.
}

/**
Expand Down Expand Up @@ -605,10 +605,10 @@
}

if ($charlist === false) {
return mb_ltrim($str);

Check failure on line 608 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_ltrim not found.
}

return mb_ltrim($str, $charlist);

Check failure on line 611 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_ltrim not found.
}

/**
Expand All @@ -632,10 +632,10 @@
}

if ($charlist === false) {
return mb_rtrim($str);

Check failure on line 635 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_rtrim not found.
}

return mb_rtrim($str, $charlist);

Check failure on line 638 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_rtrim not found.
}

/**
Expand All @@ -659,10 +659,10 @@
}

if ($charlist === false) {
return mb_trim($str);

Check failure on line 662 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_trim not found.
}

return mb_trim($str, $charlist);

Check failure on line 665 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_trim not found.
}

/**
Expand All @@ -684,14 +684,14 @@
public static function ucfirst($str, $delimiter = null, $newDelimiter = null)
{
if ($delimiter === null) {
return mb_ucfirst($str);

Check failure on line 687 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Function mb_ucfirst not found.
}

if ($newDelimiter === null) {
$newDelimiter = $delimiter;
}

return implode($newDelimiter, array_map('mb_ucfirst', explode($delimiter, $str)));

Check failure on line 694 in src/StringHelper.php

View workflow job for this annotation

GitHub Actions / framework-ci / Run PHPstan

Parameter #1 $callback of function array_map expects (callable(string): mixed)|null, 'mb_ucfirst' given.
}

/**
Expand Down Expand Up @@ -880,10 +880,8 @@
/**
* Tests whether a string complies as UTF-8.
*
* This will be much faster than StringHelper::valid() but will pass five and six octet UTF-8 sequences, which are not supported by Unicode and
* so cannot be displayed correctly in a browser. In other words it is not as strict as StringHelper::valid() but it's faster. If you use it to
* validate user input, you place yourself at the risk that attackers will be able to inject 5 and 6 byte sequences (which may or may not be a
* significant risk, depending on what you are are doing).
* Uses the UTF-8 validation of PCRE, which rejects five and six octet sequences, overlong forms, surrogates, code points above U+10FFFF
* and incomplete multi-byte sequences.
*
* @param string $str UTF-8 string to check
*
Expand Down
Loading