Skip to content

Commit ac45be2

Browse files
committed
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.
1 parent 4ee48c4 commit ac45be2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Console/Helper/Helper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function getHelperSet()
4747
*/
4848
public static function strlen($string)
4949
{
50+
$string = (string) $string;
51+
5052
if (false === $encoding = mb_detect_encoding($string, null, true)) {
5153
return \strlen($string);
5254
}
@@ -65,6 +67,8 @@ public static function strlen($string)
6567
*/
6668
public static function substr($string, $from, $length = null)
6769
{
70+
$string = (string) $string;
71+
6872
if (false === $encoding = mb_detect_encoding($string, null, true)) {
6973
return substr($string, $from, $length);
7074
}

0 commit comments

Comments
 (0)