| Zeile 65... |
Zeile 65... |
| 65 |
if ('' !== $output && "\n" !== $output[-1]) {
|
65 |
if ('' !== $output && "\n" !== $output[-1]) {
|
| 66 |
$output .= "\n";
|
66 |
$output .= "\n";
|
| 67 |
}
|
67 |
}
|
| Zeile 68... |
Zeile 68... |
| 68 |
|
68 |
|
| 69 |
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && str_contains($value, "\n") && !str_contains($value, "\r")) {
|
- |
|
| 70 |
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
- |
|
| 71 |
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
69 |
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && str_contains($value, "\n") && !str_contains($value, "\r")) {
|
| Zeile 72... |
Zeile 70... |
| 72 |
$blockIndentationIndicator = str_starts_with($value, ' ') ? (string) $this->indentation : '';
|
70 |
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value);
|
| 73 |
|
71 |
|
| 74 |
if (isset($value[-2]) && "\n" === $value[-2] && "\n" === $value[-1]) {
|
72 |
if (isset($value[-2]) && "\n" === $value[-2] && "\n" === $value[-1]) {
|
| 75 |
$blockChompingIndicator = '+';
|
73 |
$blockChompingIndicator = '+';
|
| Zeile 94... |
Zeile 92... |
| 94 |
|
92 |
|
| 95 |
if ($value instanceof TaggedValue) {
|
93 |
if ($value instanceof TaggedValue) {
|
| Zeile 96... |
Zeile 94... |
| 96 |
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
|
94 |
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
|
| 97 |
|
- |
|
| 98 |
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
|
- |
|
| 99 |
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
95 |
|
| 100 |
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
96 |
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
|
| Zeile 101... |
Zeile 97... |
| 101 |
$blockIndentationIndicator = str_starts_with($value->getValue(), ' ') ? (string) $this->indentation : '';
|
97 |
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue());
|
| 102 |
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
98 |
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
| 103 |
|
99 |
|
| Zeile 141... |
Zeile 137... |
| 141 |
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix): string
|
137 |
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix): string
|
| 142 |
{
|
138 |
{
|
| 143 |
$output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
|
139 |
$output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
|
| Zeile 144... |
Zeile 140... |
| 144 |
|
140 |
|
| 145 |
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
|
- |
|
| 146 |
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
- |
|
| 147 |
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
141 |
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
|
| 148 |
$blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : '';
|
142 |
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue());
|
| Zeile 149... |
Zeile 143... |
| 149 |
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
143 |
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
| 150 |
|
144 |
|
| 151 |
foreach (explode("\n", $value->getValue()) as $row) {
|
145 |
foreach (explode("\n", $value->getValue()) as $row) {
|
| Zeile 159... |
Zeile 153... |
| 159 |
return $output.' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
|
153 |
return $output.' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
|
| 160 |
}
|
154 |
}
|
| Zeile 161... |
Zeile 155... |
| 161 |
|
155 |
|
| 162 |
return $output."\n".$this->dump($value->getValue(), $inline - 1, $indent, $flags);
|
156 |
return $output."\n".$this->dump($value->getValue(), $inline - 1, $indent, $flags);
|
| - |
|
157 |
}
|
| - |
|
158 |
|
| - |
|
159 |
private function getBlockIndentationIndicator(string $value): string
|
| - |
|
160 |
{
|
| - |
|
161 |
$lines = explode("\n", $value);
|
| - |
|
162 |
|
| - |
|
163 |
// If the first line (that is neither empty nor contains only spaces)
|
| - |
|
164 |
// starts with a space character, the spec requires a block indentation indicator
|
| - |
|
165 |
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
| - |
|
166 |
foreach ($lines as $line) {
|
| - |
|
167 |
if ('' !== trim($line, ' ')) {
|
| - |
|
168 |
return (' ' === substr($line, 0, 1)) ? (string) $this->indentation : '';
|
| - |
|
169 |
}
|
| - |
|
170 |
}
|
| - |
|
171 |
|
| - |
|
172 |
return '';
|
| 163 |
}
|
173 |
}
|