ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Symfony\Component\Yaml\Escaper Class Reference

Escaper encapsulates escaping rules for single and double-quoted YAML strings. More...

+ Collaboration diagram for Symfony\Component\Yaml\Escaper:

Static Public Member Functions

static requiresDoubleQuoting ($value)
 Determines if a PHP value would require double quoting in YAML. More...
 
static escapeWithDoubleQuotes ($value)
 Escapes and surrounds a PHP value with double quotes. More...
 
static requiresSingleQuoting ($value)
 Determines if a PHP value would require single quoting in YAML. More...
 
static escapeWithSingleQuotes ($value)
 Escapes and surrounds a PHP value with single quotes. More...
 

Data Fields

const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"
 

Static Private Attributes

static $escapees
 
static $escaped
 

Detailed Description

Escaper encapsulates escaping rules for single and double-quoted YAML strings.

Author
Matthew Lewinski matth.nosp@m.ew@l.nosp@m.ewins.nosp@m.ki.o.nosp@m.rg

Definition at line 22 of file Escaper.php.

Member Function Documentation

◆ escapeWithDoubleQuotes()

static Symfony\Component\Yaml\Escaper::escapeWithDoubleQuotes (   $value)
static

Escapes and surrounds a PHP value with double quotes.

Parameters
string$valueA PHP value
Returns
string The quoted, escaped string

Definition at line 63 of file Escaper.php.

Referenced by Symfony\Component\Yaml\Inline\dump().

64  {
65  return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value));
66  }
+ Here is the caller graph for this function:

◆ escapeWithSingleQuotes()

static Symfony\Component\Yaml\Escaper::escapeWithSingleQuotes (   $value)
static

Escapes and surrounds a PHP value with single quotes.

Parameters
string$valueA PHP value
Returns
string The quoted, escaped string

Definition at line 95 of file Escaper.php.

Referenced by Symfony\Component\Yaml\Inline\dump().

96  {
97  return sprintf("'%s'", str_replace('\'', '\'\'', $value));
98  }
+ Here is the caller graph for this function:

◆ requiresDoubleQuoting()

static Symfony\Component\Yaml\Escaper::requiresDoubleQuoting (   $value)
static

Determines if a PHP value would require double quoting in YAML.

Parameters
string$valueA PHP value
Returns
bool True if the value would require double quotes

Definition at line 51 of file Escaper.php.

Referenced by Symfony\Component\Yaml\Inline\dump().

52  {
53  return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
54  }
+ Here is the caller graph for this function:

◆ requiresSingleQuoting()

static Symfony\Component\Yaml\Escaper::requiresSingleQuoting (   $value)
static

Determines if a PHP value would require single quoting in YAML.

Parameters
string$valueA PHP value
Returns
bool True if the value would require single quotes

Definition at line 75 of file Escaper.php.

References array.

Referenced by Symfony\Component\Yaml\Inline\dump().

76  {
77  // Determines if a PHP value is entirely composed of a value that would
78  // require single quoting in YAML.
79  if (in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) {
80  return true;
81  }
82 
83  // Determines if the PHP value contains any single characters that would
84  // cause it to require single quoting in YAML.
85  return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
86  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

Field Documentation

◆ $escaped

Symfony\Component\Yaml\Escaper::$escaped
staticprivate
Initial value:
= array('\\\\', '\\"', '\\\\', '\\"',
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
'\\N', '\\_', '\\L', '\\P')

Definition at line 37 of file Escaper.php.

◆ $escapees

Symfony\Component\Yaml\Escaper::$escapees
staticprivate
Initial value:
= array('\\', '\\\\', '\\"', '"',
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9")

Definition at line 31 of file Escaper.php.

◆ REGEX_CHARACTER_TO_ESCAPE

const Symfony\Component\Yaml\Escaper::REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"

Definition at line 25 of file Escaper.php.


The documentation for this class was generated from the following file: