-
-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Labels
Description
The MBString polyfill supports PHP >= 7.2 but it makes use of the ValueError
exception class, which was only introduced in PHP 8.
In a lot of instances, there is a version check before it is used, and in these cases there is no problem.
However, there are three unguarded locations that refer to the class, which will result in fatal errors on PHP 7:
polyfill/src/Mbstring/Mbstring.php
Lines 837 to 841 in 731f6e1
public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null): string | |
{ | |
if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) { | |
throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH'); | |
} |
polyfill/src/Mbstring/Mbstring.php
Lines 849 to 851 in 731f6e1
if (self::mb_strlen($pad_string, $encoding) <= 0) { | |
throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string'); | |
} |
polyfill/src/Mbstring/Mbstring.php
Lines 1040 to 1043 in 731f6e1
// BC for PHP 7.3 and lower | |
if (!$validEncoding) { | |
throw new \ValueError(sprintf($errorFormat, $encoding)); | |
} |