In calls to mb_ functions, silently transform arg into string
In PHP8, a number of functions who were accepting null arguments will only accept string ones. In the polyfill, mb_* functions are declared with a trict type checking of "string". Therefore, we deprecate the use of non string arguments, so that it won't break when either using the polyfill, or future php8 versions.
This commit is contained in:
parent
4ee48c44e5
commit
ac45be2580
@ -47,6 +47,8 @@ abstract class Helper implements HelperInterface
|
|||||||
*/
|
*/
|
||||||
public static function strlen($string)
|
public static function strlen($string)
|
||||||
{
|
{
|
||||||
|
$string = (string) $string;
|
||||||
|
|
||||||
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
||||||
return \strlen($string);
|
return \strlen($string);
|
||||||
}
|
}
|
||||||
@ -65,6 +67,8 @@ abstract class Helper implements HelperInterface
|
|||||||
*/
|
*/
|
||||||
public static function substr($string, $from, $length = null)
|
public static function substr($string, $from, $length = null)
|
||||||
{
|
{
|
||||||
|
$string = (string) $string;
|
||||||
|
|
||||||
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
||||||
return substr($string, $from, $length);
|
return substr($string, $from, $length);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user