update v1.0.6
This commit is contained in:
37
vendor/symfony/yaml/Parser.php
vendored
37
vendor/symfony/yaml/Parser.php
vendored
@@ -238,10 +238,6 @@ class Parser
|
||||
if ($isRef) {
|
||||
$this->refs[$isRef] = $data[$key];
|
||||
}
|
||||
|
||||
if ($objectForMap && !is_object($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
} else {
|
||||
// multiple documents are not supported
|
||||
if ('---' === $this->currentLine) {
|
||||
@@ -305,6 +301,10 @@ class Parser
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
|
||||
if ($objectForMap && !is_object($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
return empty($data) ? null : $data;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,11 @@ class Parser
|
||||
private function getNextEmbedBlock($indentation = null, $inSequence = false)
|
||||
{
|
||||
$oldLineIndentation = $this->getCurrentLineIndentation();
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
$blockScalarIndentations = array();
|
||||
|
||||
if ($this->isBlockScalarHeader()) {
|
||||
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||
}
|
||||
|
||||
if (!$this->moveToNextLine()) {
|
||||
return;
|
||||
@@ -378,8 +382,8 @@ class Parser
|
||||
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
||||
|
||||
if (!$insideBlockScalar) {
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) {
|
||||
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||
}
|
||||
|
||||
$previousLineIndentation = $this->getCurrentLineIndentation();
|
||||
@@ -387,8 +391,17 @@ class Parser
|
||||
while ($this->moveToNextLine()) {
|
||||
$indent = $this->getCurrentLineIndentation();
|
||||
|
||||
if (!$insideBlockScalar && $indent === $previousLineIndentation) {
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
// terminate all block scalars that are more indented than the current line
|
||||
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && trim($this->currentLine) !== '') {
|
||||
foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
|
||||
if ($blockScalarIndentation >= $this->getCurrentLineIndentation()) {
|
||||
unset($blockScalarIndentations[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) {
|
||||
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||
}
|
||||
|
||||
$previousLineIndentation = $indent;
|
||||
@@ -404,7 +417,7 @@ class Parser
|
||||
}
|
||||
|
||||
// we ignore "comment" lines only when we are not inside a scalar block
|
||||
if (!$insideBlockScalar && $this->isCurrentLineComment()) {
|
||||
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -569,7 +582,7 @@ class Parser
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
|
||||
for ($i = 0; $i < count($blockLines); $i++) {
|
||||
for ($i = 0; $i < count($blockLines); ++$i) {
|
||||
if ('' === $blockLines[$i]) {
|
||||
$text .= "\n";
|
||||
$previousLineIndented = false;
|
||||
@@ -664,7 +677,7 @@ class Parser
|
||||
//checking explicitly the first char of the trim is faster than loops or strpos
|
||||
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
||||
|
||||
return $ltrimmedLine[0] === '#';
|
||||
return '' !== $ltrimmedLine && $ltrimmedLine[0] === '#';
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user