Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/yaml/Dumper.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 |
---|---|
63 * | 63 * |
64 * @return string The YAML representation of the PHP value | 64 * @return string The YAML representation of the PHP value |
65 */ | 65 */ |
66 public function dump($input, $inline = 0, $indent = 0, $flags = 0) | 66 public function dump($input, $inline = 0, $indent = 0, $flags = 0) |
67 { | 67 { |
68 if (is_bool($flags)) { | 68 if (\is_bool($flags)) { |
69 @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 Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); | 69 @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 Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); |
70 | 70 |
71 if ($flags) { | 71 if ($flags) { |
72 $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE; | 72 $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE; |
73 } else { | 73 } else { |
74 $flags = 0; | 74 $flags = 0; |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 if (func_num_args() >= 5) { | 78 if (\func_num_args() >= 5) { |
79 @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 Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED); | 79 @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 Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED); |
80 | 80 |
81 if (func_get_arg(4)) { | 81 if (func_get_arg(4)) { |
82 $flags |= Yaml::DUMP_OBJECT; | 82 $flags |= Yaml::DUMP_OBJECT; |
83 } | 83 } |
89 | 89 |
90 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { | 90 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { |
91 $dumpObjectAsInlineMap = empty((array) $input); | 91 $dumpObjectAsInlineMap = empty((array) $input); |
92 } | 92 } |
93 | 93 |
94 if ($inline <= 0 || (!is_array($input) && $dumpObjectAsInlineMap) || empty($input)) { | 94 if ($inline <= 0 || (!\is_array($input) && $dumpObjectAsInlineMap) || empty($input)) { |
95 $output .= $prefix.Inline::dump($input, $flags); | 95 $output .= $prefix.Inline::dump($input, $flags); |
96 } else { | 96 } else { |
97 $dumpAsMap = Inline::isHash($input); | 97 $dumpAsMap = Inline::isHash($input); |
98 | 98 |
99 foreach ($input as $key => $value) { | 99 foreach ($input as $key => $value) { |
100 if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) { | 100 if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) { |
101 // If the first line starts with a space character, the spec requires a blockIndicationIndicator | 101 // If the first line starts with a space character, the spec requires a blockIndicationIndicator |
102 // http://www.yaml.org/spec/1.2/spec.html#id2793979 | 102 // http://www.yaml.org/spec/1.2/spec.html#id2793979 |
103 $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; | 103 $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; |
104 $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); | 104 $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); |
105 | 105 |
114 | 114 |
115 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { | 115 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { |
116 $dumpObjectAsInlineMap = empty((array) $value); | 116 $dumpObjectAsInlineMap = empty((array) $value); |
117 } | 117 } |
118 | 118 |
119 $willBeInlined = $inline - 1 <= 0 || !is_array($value) && $dumpObjectAsInlineMap || empty($value); | 119 $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value); |
120 | 120 |
121 $output .= sprintf('%s%s%s%s', | 121 $output .= sprintf('%s%s%s%s', |
122 $prefix, | 122 $prefix, |
123 $dumpAsMap ? Inline::dump($key, $flags).':' : '-', | 123 $dumpAsMap ? Inline::dump($key, $flags).':' : '-', |
124 $willBeInlined ? ' ' : "\n", | 124 $willBeInlined ? ' ' : "\n", |