Pull merge.
[yaffs-website] / vendor / symfony / yaml / Unescaper.php
index 1e02cc9fd808608015bab6843792ff9c53228afb..6a12999deb7b61324ba55d90473735a60a4752b5 100644 (file)
@@ -11,6 +11,8 @@
 
 namespace Symfony\Component\Yaml;
 
+use Symfony\Component\Yaml\Exception\ParseException;
+
 /**
  * Unescaper encapsulates unescaping rules for single and double-quoted
  * YAML strings.
@@ -21,16 +23,6 @@ namespace Symfony\Component\Yaml;
  */
 class Unescaper
 {
-    /**
-     * Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
-     * must be converted to that encoding.
-     *
-     * @deprecated since version 2.5, to be removed in 3.0
-     *
-     * @internal
-     */
-    const ENCODING = 'UTF-8';
-
     /**
      * Regex fragment that matches an escaped character in a double quoted string.
      */
@@ -57,9 +49,8 @@ class Unescaper
      */
     public function unescapeDoubleQuotedString($value)
     {
-        $self = $this;
-        $callback = function ($match) use ($self) {
-            return $self->unescapeCharacter($match[0]);
+        $callback = function ($match) {
+            return $this->unescapeCharacter($match[0]);
         };
 
         // evaluate the string
@@ -72,11 +63,8 @@ class Unescaper
      * @param string $value An escaped character
      *
      * @return string The unescaped character
-     *
-     * @internal This method is public to be usable as callback. It should not
-     *           be used in user code. Should be changed in 3.0.
      */
-    public function unescapeCharacter($value)
+    private function unescapeCharacter($value)
     {
         switch ($value[1]) {
             case '0':
@@ -126,9 +114,7 @@ class Unescaper
             case 'U':
                 return self::utf8chr(hexdec(substr($value, 2, 8)));
             default:
-                @trigger_error('Not escaping a backslash in a double-quoted string is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', E_USER_DEPRECATED);
-
-                return $value;
+                throw new ParseException(sprintf('Found unknown escape character "%s".', $value));
         }
     }
 
@@ -142,15 +128,15 @@ class Unescaper
     private static function utf8chr($c)
     {
         if (0x80 > $c %= 0x200000) {
-            return chr($c);
+            return \chr($c);
         }
         if (0x800 > $c) {
-            return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
+            return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F);
         }
         if (0x10000 > $c) {
-            return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
+            return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
         }
 
-        return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
+        return \chr(0xF0 | $c >> 18).\chr(0x80 | $c >> 12 & 0x3F).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
     }
 }