Fix #1553 downgrade symfony packages to 1.19, for compatibility with PHP 7.0

This commit is contained in:
Kijin Sung 2021-01-09 16:13:15 +09:00
parent f4ad0dbb48
commit 790434ad32
43 changed files with 1465 additions and 965 deletions

View file

@ -36,14 +36,14 @@ namespace Symfony\Polyfill\Iconv;
*/
final class Iconv
{
public const ERROR_ILLEGAL_CHARACTER = 'iconv(): Detected an illegal character in input string';
public const ERROR_WRONG_CHARSET = 'iconv(): Wrong charset, conversion from `%s\' to `%s\' is not allowed';
const ERROR_ILLEGAL_CHARACTER = 'iconv(): Detected an illegal character in input string';
const ERROR_WRONG_CHARSET = 'iconv(): Wrong charset, conversion from `%s\' to `%s\' is not allowed';
public static $inputEncoding = 'utf-8';
public static $outputEncoding = 'utf-8';
public static $internalEncoding = 'utf-8';
private static $alias = [
private static $alias = array(
'utf8' => 'utf-8',
'ascii' => 'us-ascii',
'tis-620' => 'iso-8859-11',
@ -116,13 +116,13 @@ final class Iconv
'iso885914' => 'iso-8859-14',
'iso885915' => 'iso-8859-15',
'iso885916' => 'iso-8859-16',
];
private static $translitMap = [];
private static $convertMap = [];
);
private static $translitMap = array();
private static $convertMap = array();
private static $errorHandler;
private static $lastError;
private static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
private static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
private static $isValidUtf8;
public static function iconv($inCharset, $outCharset, $str)
@ -238,7 +238,7 @@ final class Iconv
}
$str = explode("\n\n", $str, 2);
$headers = [];
$headers = array();
$str = preg_split('/\n(?![ \t])/', $str[0]);
foreach ($str as $str) {
@ -251,7 +251,7 @@ final class Iconv
if (2 === \count($str)) {
if (isset($headers[$str[0]])) {
if (!\is_array($headers[$str[0]])) {
$headers[$str[0]] = [$headers[$str[0]]];
$headers[$str[0]] = array($headers[$str[0]]);
}
$headers[$str[0]][] = ltrim($str[1]);
} else {
@ -268,7 +268,7 @@ final class Iconv
if (null === $charset) {
$charset = self::$internalEncoding;
}
if (\ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
if (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
$charset .= '//IGNORE';
}
@ -277,7 +277,7 @@ final class Iconv
}
$str = preg_split('/\n(?![ \t])/', rtrim($str), 2);
$str = preg_replace('/[ \t]*\n[ \t]+/', ' ', rtrim($str[0]));
$str = preg_split('/=\?([^?]+)\?([bqBQ])\?(.*?)\?=/', $str, -1, \PREG_SPLIT_DELIM_CAPTURE);
$str = preg_split('/=\?([^?]+)\?([bqBQ])\?(.*?)\?=/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
$result = self::iconv('utf-8', $charset, $str[0]);
if (false === $result) {
@ -289,7 +289,7 @@ final class Iconv
while ($i < $len) {
$c = strtolower($str[$i]);
if ((\ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode)
if ((ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode)
&& 'utf-8' !== $c
&& !isset(self::$alias[$c])
&& !self::loadMap('from.', $c, $d)) {
@ -312,7 +312,7 @@ final class Iconv
if ('' !== trim($d)) {
$result .= $d;
}
} elseif (\ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
} elseif (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
$result .= "=?{$str[$i]}?{$str[$i + 1]}?{$str[$i + 2]}?={$str[$i + 3]}";
} else {
$result = false;
@ -333,11 +333,11 @@ final class Iconv
case 'internal_encoding': return self::$internalEncoding;
}
return [
return array(
'input_encoding' => self::$inputEncoding,
'output_encoding' => self::$outputEncoding,
'internal_encoding' => self::$internalEncoding,
];
);
}
public static function iconv_set_encoding($type, $charset)
@ -346,6 +346,7 @@ final class Iconv
case 'input_encoding': self::$inputEncoding = $charset; break;
case 'output_encoding': self::$outputEncoding = $charset; break;
case 'internal_encoding': self::$internalEncoding = $charset; break;
default: return false;
}
@ -355,16 +356,16 @@ final class Iconv
public static function iconv_mime_encode($fieldName, $fieldValue, $pref = null)
{
if (!\is_array($pref)) {
$pref = [];
$pref = array();
}
$pref += [
$pref += array(
'scheme' => 'B',
'input-charset' => self::$internalEncoding,
'output-charset' => self::$internalEncoding,
'line-length' => 76,
'line-break-chars' => "\r\n",
];
);
if (preg_match('/[\x80-\xFF]/', $fieldName)) {
$fieldName = '';
@ -380,7 +381,7 @@ final class Iconv
preg_match_all('/./us', $fieldValue, $chars);
$chars = $chars[0] ?? [];
$chars = isset($chars[0]) ? $chars[0] : array();
$lineBreak = (int) $pref['line-length'];
$lineStart = "=?{$pref['output-charset']}?{$scheme}?";
@ -388,7 +389,7 @@ final class Iconv
$lineOffset = \strlen($lineStart) + 3;
$lineData = '';
$fieldValue = [];
$fieldValue = array();
$Q = 'Q' === $scheme;
@ -400,7 +401,7 @@ final class Iconv
$o = $Q
? $c = preg_replace_callback(
'/[=_\?\x00-\x1F\x80-\xFF]/',
[__CLASS__, 'qpByteCallback'],
array(__CLASS__, 'qpByteCallback'),
$c
)
: base64_encode($lineData.$c);
@ -471,7 +472,7 @@ final class Iconv
while ($i < $len) {
$u = $s[$i] & "\xF0";
$i += $ulenMask[$u] ?? 1;
$i += isset($ulenMask[$u]) ? $ulenMask[$u] : 1;
++$j;
}
@ -610,7 +611,7 @@ final class Iconv
$u[$j++] = $str[$i++];
} else {
$ulen = $str[$i] & "\xF0";
$ulen = $ulenMask[$ulen] ?? 1;
$ulen = isset($ulenMask[$ulen]) ? $ulenMask[$ulen] : 1;
$uchr = substr($str, $i, $ulen);
if (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr))) {
@ -622,10 +623,10 @@ final class Iconv
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
return false;
} else {
$i += $ulen;
}
$i += $ulen;
$u[$j++] = $uchr[0];
isset($uchr[1]) && 0 !== ($u[$j++] = $uchr[1])
@ -672,15 +673,15 @@ final class Iconv
$uchr = $str[$i++];
} else {
$ulen = $str[$i] & "\xF0";
$ulen = $ulenMask[$ulen] ?? 1;
$ulen = isset($ulenMask[$ulen]) ? $ulenMask[$ulen] : 1;
$uchr = substr($str, $i, $ulen);
if ($ignore && (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr)))) {
++$i;
continue;
} else {
$i += $ulen;
}
$i += $ulen;
}
if (isset($map[$uchr])) {
@ -722,7 +723,7 @@ final class Iconv
private static function pregOffset($offset)
{
$rx = [];
$rx = array();
$offset = (int) $offset;
while ($offset > 65535) {