Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/yaml/Yaml.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
15 | 15 |
16 /** | 16 /** |
17 * Yaml offers convenience methods to load and dump YAML. | 17 * Yaml offers convenience methods to load and dump YAML. |
18 * | 18 * |
19 * @author Fabien Potencier <fabien@symfony.com> | 19 * @author Fabien Potencier <fabien@symfony.com> |
20 * | |
21 * @final since version 3.4 | |
20 */ | 22 */ |
21 class Yaml | 23 class Yaml |
22 { | 24 { |
23 const DUMP_OBJECT = 1; | 25 const DUMP_OBJECT = 1; |
24 const PARSE_EXCEPTION_ON_INVALID_TYPE = 2; | 26 const PARSE_EXCEPTION_ON_INVALID_TYPE = 2; |
27 const DUMP_EXCEPTION_ON_INVALID_TYPE = 16; | 29 const DUMP_EXCEPTION_ON_INVALID_TYPE = 16; |
28 const PARSE_DATETIME = 32; | 30 const PARSE_DATETIME = 32; |
29 const DUMP_OBJECT_AS_MAP = 64; | 31 const DUMP_OBJECT_AS_MAP = 64; |
30 const DUMP_MULTI_LINE_LITERAL_BLOCK = 128; | 32 const DUMP_MULTI_LINE_LITERAL_BLOCK = 128; |
31 const PARSE_CONSTANT = 256; | 33 const PARSE_CONSTANT = 256; |
34 const PARSE_CUSTOM_TAGS = 512; | |
35 const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024; | |
36 | |
37 /** | |
38 * @deprecated since version 3.4, to be removed in 4.0. Quote your evaluable keys instead. | |
39 */ | |
40 const PARSE_KEYS_AS_STRINGS = 2048; | |
41 | |
42 /** | |
43 * Parses a YAML file into a PHP value. | |
44 * | |
45 * Usage: | |
46 * <code> | |
47 * $array = Yaml::parseFile('config.yml'); | |
48 * print_r($array); | |
49 * </code> | |
50 * | |
51 * @param string $filename The path to the YAML file to be parsed | |
52 * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior | |
53 * | |
54 * @return mixed The YAML converted to a PHP value | |
55 * | |
56 * @throws ParseException If the file could not be read or the YAML is not valid | |
57 */ | |
58 public static function parseFile($filename, $flags = 0) | |
59 { | |
60 $yaml = new Parser(); | |
61 | |
62 return $yaml->parseFile($filename, $flags); | |
63 } | |
32 | 64 |
33 /** | 65 /** |
34 * Parses YAML into a PHP value. | 66 * Parses YAML into a PHP value. |
35 * | 67 * |
36 * Usage: | 68 * Usage: |
47 * @throws ParseException If the YAML is not valid | 79 * @throws ParseException If the YAML is not valid |
48 */ | 80 */ |
49 public static function parse($input, $flags = 0) | 81 public static function parse($input, $flags = 0) |
50 { | 82 { |
51 if (is_bool($flags)) { | 83 if (is_bool($flags)) { |
52 @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); | 84 @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); |
53 | 85 |
54 if ($flags) { | 86 if ($flags) { |
55 $flags = self::PARSE_EXCEPTION_ON_INVALID_TYPE; | 87 $flags = self::PARSE_EXCEPTION_ON_INVALID_TYPE; |
56 } else { | 88 } else { |
57 $flags = 0; | 89 $flags = 0; |
58 } | 90 } |
59 } | 91 } |
60 | 92 |
61 if (func_num_args() >= 3) { | 93 if (func_num_args() >= 3) { |
62 @trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED); | 94 @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED); |
63 | 95 |
64 if (func_get_arg(2)) { | 96 if (func_get_arg(2)) { |
65 $flags |= self::PARSE_OBJECT; | 97 $flags |= self::PARSE_OBJECT; |
66 } | 98 } |
67 } | 99 } |
68 | 100 |
69 if (func_num_args() >= 4) { | 101 if (func_num_args() >= 4) { |
70 @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED); | 102 @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED); |
71 | 103 |
72 if (func_get_arg(3)) { | 104 if (func_get_arg(3)) { |
73 $flags |= self::PARSE_OBJECT_FOR_MAP; | 105 $flags |= self::PARSE_OBJECT_FOR_MAP; |
74 } | 106 } |
75 } | 107 } |
93 * @return string A YAML string representing the original PHP value | 125 * @return string A YAML string representing the original PHP value |
94 */ | 126 */ |
95 public static function dump($input, $inline = 2, $indent = 4, $flags = 0) | 127 public static function dump($input, $inline = 2, $indent = 4, $flags = 0) |
96 { | 128 { |
97 if (is_bool($flags)) { | 129 if (is_bool($flags)) { |
98 @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); | 130 @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); |
99 | 131 |
100 if ($flags) { | 132 if ($flags) { |
101 $flags = self::DUMP_EXCEPTION_ON_INVALID_TYPE; | 133 $flags = self::DUMP_EXCEPTION_ON_INVALID_TYPE; |
102 } else { | 134 } else { |
103 $flags = 0; | 135 $flags = 0; |
104 } | 136 } |
105 } | 137 } |
106 | 138 |
107 if (func_num_args() >= 5) { | 139 if (func_num_args() >= 5) { |
108 @trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED); | 140 @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED); |
109 | 141 |
110 if (func_get_arg(4)) { | 142 if (func_get_arg(4)) { |
111 $flags |= self::DUMP_OBJECT; | 143 $flags |= self::DUMP_OBJECT; |
112 } | 144 } |
113 } | 145 } |