Skip to content
  • Sponsor symfony/polyfill-mbstring

  • Notifications You must be signed in to change notification settings
  • Fork 39
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f9c7aff

Browse files
jeremyFreeAgentnicolas-grekas
authored andcommittedJan 30, 2023
add mb_check_encoding with array value
1 parent fd9e963 commit f9c7aff

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed
 

‎Mbstring.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,34 @@ public static function mb_encoding_aliases($encoding)
406406

407407
public static function mb_check_encoding($var = null, $encoding = null)
408408
{
409+
if (PHP_VERSION_ID < 70200 && \is_array($var)) {
410+
trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
411+
412+
return null;
413+
}
414+
409415
if (null === $encoding) {
410416
if (null === $var) {
411417
return false;
412418
}
413419
$encoding = self::$internalEncoding;
414420
}
415421

416-
return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var);
422+
if (!\is_array($var)) {
423+
return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var);
424+
}
425+
426+
foreach ($var as $key => $value) {
427+
if (!self::mb_check_encoding($key, $encoding)) {
428+
return false;
429+
}
430+
if (!self::mb_check_encoding($value, $encoding)) {
431+
return false;
432+
}
433+
}
434+
435+
return true;
436+
417437
}
418438

419439
public static function mb_detect_encoding($str, $encodingList = null, $strict = false)

0 commit comments

Comments
 (0)
Failed to load comments.