modif comtabilite
This commit is contained in:
+29
-31
@@ -44,7 +44,7 @@ namespace Symfony\Polyfill\Mbstring;
|
||||
* - mb_strrchr - Finds the last occurrence of a character in a string within another
|
||||
* - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive
|
||||
* - mb_strripos - Finds position of last occurrence of a string within another, case insensitive
|
||||
* - mb_strstr - Finds first occurrence of a string within anothers
|
||||
* - mb_strstr - Finds first occurrence of a string within another
|
||||
* - mb_strwidth - Return width of string
|
||||
* - mb_substr_count - Count the number of substring occurrences
|
||||
*
|
||||
@@ -78,7 +78,7 @@ final class Mbstring
|
||||
|
||||
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
|
||||
{
|
||||
if (is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
|
||||
if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
|
||||
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
|
||||
} else {
|
||||
$fromEncoding = self::getEncoding($fromEncoding);
|
||||
@@ -140,16 +140,16 @@ final class Mbstring
|
||||
|
||||
public static function mb_decode_numericentity($s, $convmap, $encoding = null)
|
||||
{
|
||||
if (null !== $s && !is_scalar($s) && !(is_object($s) && method_exists($s, '__toString'))) {
|
||||
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
|
||||
trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.gettype($s).' given', E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($convmap) || !$convmap) {
|
||||
if (!\is_array($convmap) || !$convmap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $encoding && !is_scalar($encoding)) {
|
||||
if (null !== $encoding && !\is_scalar($encoding)) {
|
||||
trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.gettype($s).' given', E_USER_WARNING);
|
||||
return ''; // Instead of null (cf. mb_encode_numericentity).
|
||||
}
|
||||
@@ -170,7 +170,7 @@ final class Mbstring
|
||||
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
|
||||
$cnt = floor(count($convmap) / 4) * 4;
|
||||
$cnt = floor(\count($convmap) / 4) * 4;
|
||||
|
||||
for ($i = 0; $i < $cnt; $i += 4) {
|
||||
// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
|
||||
@@ -197,21 +197,21 @@ final class Mbstring
|
||||
|
||||
public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
|
||||
{
|
||||
if (null !== $s && !is_scalar($s) && !(is_object($s) && method_exists($s, '__toString'))) {
|
||||
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
|
||||
trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.gettype($s).' given', E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($convmap) || !$convmap) {
|
||||
if (!\is_array($convmap) || !$convmap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $encoding && !is_scalar($encoding)) {
|
||||
if (null !== $encoding && !\is_scalar($encoding)) {
|
||||
trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.gettype($s).' given', E_USER_WARNING);
|
||||
return null; // Instead of '' (cf. mb_decode_numericentity).
|
||||
}
|
||||
|
||||
if (null !== $is_hex && !is_scalar($is_hex)) {
|
||||
if (null !== $is_hex && !\is_scalar($is_hex)) {
|
||||
trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.gettype($s).' given', E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
@@ -234,9 +234,9 @@ final class Mbstring
|
||||
|
||||
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
||||
|
||||
$cnt = floor(count($convmap) / 4) * 4;
|
||||
$cnt = floor(\count($convmap) / 4) * 4;
|
||||
$i = 0;
|
||||
$len = strlen($s);
|
||||
$len = \strlen($s);
|
||||
$result = '';
|
||||
|
||||
while ($i < $len) {
|
||||
@@ -281,8 +281,11 @@ final class Mbstring
|
||||
}
|
||||
|
||||
if (MB_CASE_TITLE == $mode) {
|
||||
$s = preg_replace_callback('/\b\p{Ll}/u', array(__CLASS__, 'title_case_upper'), $s);
|
||||
$s = preg_replace_callback('/\B[\p{Lu}\p{Lt}]+/u', array(__CLASS__, 'title_case_lower'), $s);
|
||||
static $titleRegexp = null;
|
||||
if (null === $titleRegexp) {
|
||||
$titleRegexp = self::getData('titleCaseRegexp');
|
||||
}
|
||||
$s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
|
||||
} else {
|
||||
if (MB_CASE_UPPER == $mode) {
|
||||
static $upper = null;
|
||||
@@ -305,7 +308,7 @@ final class Mbstring
|
||||
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
||||
|
||||
$i = 0;
|
||||
$len = strlen($s);
|
||||
$len = \strlen($s);
|
||||
|
||||
while ($i < $len) {
|
||||
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
||||
@@ -314,7 +317,7 @@ final class Mbstring
|
||||
|
||||
if (isset($map[$uchr])) {
|
||||
$uchr = $map[$uchr];
|
||||
$nlen = strlen($uchr);
|
||||
$nlen = \strlen($uchr);
|
||||
|
||||
if ($nlen == $ulen) {
|
||||
$nlen = $i;
|
||||
@@ -404,7 +407,7 @@ final class Mbstring
|
||||
if (null === $encodingList) {
|
||||
$encodingList = self::$encodingList;
|
||||
} else {
|
||||
if (!is_array($encodingList)) {
|
||||
if (!\is_array($encodingList)) {
|
||||
$encodingList = array_map('trim', explode(',', $encodingList));
|
||||
}
|
||||
$encodingList = array_map('strtoupper', $encodingList);
|
||||
@@ -441,7 +444,7 @@ final class Mbstring
|
||||
return self::$encodingList;
|
||||
}
|
||||
|
||||
if (!is_array($encodingList)) {
|
||||
if (!\is_array($encodingList)) {
|
||||
$encodingList = array_map('trim', explode(',', $encodingList));
|
||||
}
|
||||
$encodingList = array_map('strtoupper', $encodingList);
|
||||
@@ -467,7 +470,7 @@ final class Mbstring
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
||||
return strlen($s);
|
||||
return \strlen($s);
|
||||
}
|
||||
|
||||
return @iconv_strlen($s, $encoding);
|
||||
@@ -679,13 +682,13 @@ final class Mbstring
|
||||
public static function mb_chr($code, $encoding = null)
|
||||
{
|
||||
if (0x80 > $code %= 0x200000) {
|
||||
$s = chr($code);
|
||||
$s = \chr($code);
|
||||
} elseif (0x800 > $code) {
|
||||
$s = chr(0xC0 | $code >> 6).chr(0x80 | $code & 0x3F);
|
||||
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
|
||||
} elseif (0x10000 > $code) {
|
||||
$s = chr(0xE0 | $code >> 12).chr(0x80 | $code >> 6 & 0x3F).chr(0x80 | $code & 0x3F);
|
||||
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
||||
} else {
|
||||
$s = chr(0xF0 | $code >> 18).chr(0x80 | $code >> 12 & 0x3F).chr(0x80 | $code >> 6 & 0x3F).chr(0x80 | $code & 0x3F);
|
||||
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
||||
}
|
||||
|
||||
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
||||
@@ -735,7 +738,7 @@ final class Mbstring
|
||||
|
||||
while (isset($m[$i])) {
|
||||
if (0x80 > $m[$i]) {
|
||||
$entities .= chr($m[$i++]);
|
||||
$entities .= \chr($m[$i++]);
|
||||
continue;
|
||||
}
|
||||
if (0xF0 <= $m[$i]) {
|
||||
@@ -752,14 +755,9 @@ final class Mbstring
|
||||
return $entities;
|
||||
}
|
||||
|
||||
private static function title_case_lower(array $s)
|
||||
private static function title_case(array $s)
|
||||
{
|
||||
return self::mb_convert_case($s[0], MB_CASE_LOWER, 'UTF-8');
|
||||
}
|
||||
|
||||
private static function title_case_upper(array $s)
|
||||
{
|
||||
return self::mb_convert_case($s[0], MB_CASE_UPPER, 'UTF-8');
|
||||
return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
|
||||
}
|
||||
|
||||
private static function getData($file)
|
||||
|
||||
Reference in New Issue
Block a user