From bee5a5b7c80b477693d8600d19045385bcced9bc Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Vares Date: Mon, 22 Feb 2021 09:25:14 +0100 Subject: [PATCH] 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. --- Helper/Helper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Helper/Helper.php b/Helper/Helper.php index 0ddddf6bc..0521aaf7d 100644 --- a/Helper/Helper.php +++ b/Helper/Helper.php @@ -47,6 +47,8 @@ public function getHelperSet() */ public static function strlen($string) { + $string = (string) $string; + if (false === $encoding = mb_detect_encoding($string, null, true)) { return \strlen($string); } @@ -65,6 +67,8 @@ public static function strlen($string) */ public static function substr($string, $from, $length = null) { + $string = (string) $string; + if (false === $encoding = mb_detect_encoding($string, null, true)) { return substr($string, $from, $length); }