namespace Symfony\Component\Yaml;
+use Symfony\Component\Yaml\Exception\ParseException;
+
/**
* Unescaper encapsulates unescaping rules for single and double-quoted
* YAML strings.
*/
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.
*/
*/
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
* @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':
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));
}
}