Skip to content

Commit e61bcd0

Browse files
Merge branch '5.2' into 5.x
* 5.2: fixed parser Fixed bugs found by psalm [FrameworkBundle] Dont store cache misses on warmup fix test Update references to the ContainerConfigurator [Translation] Remove file added back from a bad merge Fix sleep value [Cache] skip storing failure-to-save as misses in ArrayAdapter [Validator] Delete obsolete statement in Regex::getHtmlPattern() phpDoc [FrameworkBundle] Remove author comments for configuration and extension [Stopwatch] Document new "name" property of StopwatchEvent [DependencyInjection] Fix "url" env var processor behavior when the url has no path Fixed support for nodes not extending BaseNode [FrameworkBundle] dont access the container to configure http_cache add missing queue_name to find(id) in doctrine messenger transport [Config][FrameworkBundle] Hint to use PHP 8+ or to install Annotations to use attributes/annots [Serializer] AbstractNormalizer force null for non-optional nullable constructor parameter denormalization when not present in input
2 parents 0887a2c + 7e46b52 commit e61bcd0

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

Parser.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,16 @@ private function doParse(string $value, int $flags)
172172
}
173173

174174
// array
175-
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
175+
if (isset($values['value']) && 0 === strpos(ltrim($values['value'], ' '), '-')) {
176+
// Inline first child
177+
$currentLineNumber = $this->getRealCurrentLineNb();
178+
179+
$sequenceIndentation = \strlen($values['leadspaces']) + 1;
180+
$sequenceYaml = substr($this->currentLine, $sequenceIndentation);
181+
$sequenceYaml .= "\n".$this->getNextEmbedBlock($sequenceIndentation, true);
182+
183+
$data[] = $this->parseBlock($currentLineNumber, rtrim($sequenceYaml), $flags);
184+
} elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
176185
$data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true) ?? '', $flags);
177186
} elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) {
178187
$data[] = new TaggedValue(
@@ -612,6 +621,7 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
612621
}
613622

614623
$data = [];
624+
615625
if ($this->getCurrentLineIndentation() >= $newIndent) {
616626
$data[] = substr($this->currentLine, $newIndent);
617627
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {

Tests/Fixtures/YtsBasicTests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,37 @@ php: |
200200
'age' => 38
201201
]
202202
]
203+
---
204+
test: Inline first element in sequence blocks 1
205+
yaml: |
206+
- - s1_i1
207+
- s1_i2
208+
- s2
209+
php: |
210+
[
211+
[
212+
"s1_i1",
213+
"s1_i2"
214+
],
215+
"s2"
216+
]
217+
---
218+
test: Inline first element in sequence blocks 2
219+
yaml: |
220+
- - s1_i1
221+
- - s1_i1_1
222+
- s1_i1_2
223+
- s1_i2
224+
- s2
225+
php: |
226+
[
227+
[
228+
"s1_i1",
229+
[
230+
"s1_i1_1",
231+
"s1_i1_2",
232+
],
233+
"s1_i2"
234+
],
235+
"s2"
236+
]

0 commit comments

Comments
 (0)