diff vendor/symfony/polyfill-iconv/Iconv.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children c2387f117808
line wrap: on
line diff
--- a/vendor/symfony/polyfill-iconv/Iconv.php	Fri Feb 23 15:51:18 2018 +0000
+++ b/vendor/symfony/polyfill-iconv/Iconv.php	Fri Feb 23 15:52:07 2018 +0000
@@ -127,7 +127,8 @@
 
     public static function iconv($inCharset, $outCharset, $str)
     {
-        if ('' === $str .= '') {
+        $str = (string) $str;
+        if ('' === $str) {
             return '';
         }
 
@@ -145,22 +146,33 @@
             $inCharset = 'iso-8859-1';
         }
 
-        if ('//translit' === substr($outCharset, -10)) {
-            $translit = '//TRANSLIT';
-            $outCharset = substr($outCharset, 0, -10);
-        }
+        do {
+            $loop = false;
 
-        if ('//ignore' === substr($outCharset, -8)) {
-            $ignore = '//IGNORE';
-            $outCharset = substr($outCharset, 0, -8);
-        }
+            if ('//translit' === substr($outCharset, -10)) {
+                $loop = $translit = true;
+                $outCharset = substr($outCharset, 0, -10);
+            }
 
-        if ('//translit' === substr($inCharset, -10)) {
-            $inCharset = substr($inCharset, 0, -10);
-        }
-        if ('//ignore' === substr($inCharset, -8)) {
-            $inCharset = substr($inCharset, 0, -8);
-        }
+            if ('//ignore' === substr($outCharset, -8)) {
+                $loop = $ignore = true;
+                $outCharset = substr($outCharset, 0, -8);
+            }
+        } while ($loop);
+
+        do {
+            $loop = false;
+
+            if ('//translit' === substr($inCharset, -10)) {
+                $loop = true;
+                $inCharset = substr($inCharset, 0, -10);
+            }
+
+            if ('//ignore' === substr($inCharset, -8)) {
+                $loop = true;
+                $inCharset = substr($inCharset, 0, -8);
+            }
+        } while ($loop);
 
         if (isset(self::$alias[ $inCharset])) {
             $inCharset = self::$alias[ $inCharset];
@@ -521,7 +533,7 @@
             return false;
         }
 
-        $s .= '';
+        $s = (string) $s;
         $slen = self::iconv_strlen($s, 'utf-8');
         $start = (int) $start;
 
@@ -622,7 +634,7 @@
         return substr($u, 0, $j);
     }
 
-    private static function mapToUtf8(&$result, $map, $str, $ignore)
+    private static function mapToUtf8(&$result, array $map, $str, $ignore)
     {
         $len = strlen($str);
         for ($i = 0; $i < $len; ++$i) {
@@ -640,7 +652,7 @@
         return true;
     }
 
-    private static function mapFromUtf8(&$result, $map, $str, $ignore, $translit)
+    private static function mapFromUtf8(&$result, array $map, $str, $ignore, $translit)
     {
         $ulenMask = self::$ulenMask;
         $valid = self::$isValidUtf8;
@@ -696,7 +708,7 @@
         return true;
     }
 
-    private static function qpByteCallback($m)
+    private static function qpByteCallback(array $m)
     {
         return '='.strtoupper(dechex(ord($m[0])));
     }