comparison vendor/symfony/yaml/Escaper.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
26 26
27 // Mapping arrays for escaping a double quoted string. The backslash is 27 // Mapping arrays for escaping a double quoted string. The backslash is
28 // first to ensure proper escaping because str_replace operates iteratively 28 // first to ensure proper escaping because str_replace operates iteratively
29 // on the input arrays. This ordering of the characters avoids the use of strtr, 29 // on the input arrays. This ordering of the characters avoids the use of strtr,
30 // which performs more slowly. 30 // which performs more slowly.
31 private static $escapees = array('\\', '\\\\', '\\"', '"', 31 private static $escapees = ['\\', '\\\\', '\\"', '"',
32 "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", 32 "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
33 "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", 33 "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
34 "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", 34 "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
35 "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", 35 "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
36 "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", 36 "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
37 ); 37 ];
38 private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', 38 private static $escaped = ['\\\\', '\\"', '\\\\', '\\"',
39 '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', 39 '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
40 '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', 40 '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
41 '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', 41 '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
42 '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', 42 '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
43 '\\N', '\\_', '\\L', '\\P', 43 '\\N', '\\_', '\\L', '\\P',
44 ); 44 ];
45 45
46 /** 46 /**
47 * Determines if a PHP value would require double quoting in YAML. 47 * Determines if a PHP value would require double quoting in YAML.
48 * 48 *
49 * @param string $value A PHP value 49 * @param string $value A PHP value
76 */ 76 */
77 public static function requiresSingleQuoting($value) 77 public static function requiresSingleQuoting($value)
78 { 78 {
79 // Determines if a PHP value is entirely composed of a value that would 79 // Determines if a PHP value is entirely composed of a value that would
80 // require single quoting in YAML. 80 // require single quoting in YAML.
81 if (in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) { 81 if (\in_array(strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'])) {
82 return true; 82 return true;
83 } 83 }
84 84
85 // Determines if the PHP value contains any single characters that would 85 // Determines if the PHP value contains any single characters that would
86 // cause it to require single quoting in YAML. 86 // cause it to require single quoting in YAML.