merged branch pvolok/fix-7274 (PR #7641)
This PR was merged into the 2.1 branch. Discussion ---------- [2.2][Yaml] Fixed resolving blank values | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7274 | License | MIT | Doc PR | - Also, Seldaek suggested to rename the $notEOF variable. Commits -------fb686d8
[Yaml] improved boolean naming ($notEOF -> !$EOF)047212a
[Yaml] fixed handling an empty value
This commit is contained in:
commit
c8889c2c73
@ -102,7 +102,7 @@ class Parser
|
|||||||
$parser->refs =& $this->refs;
|
$parser->refs =& $this->refs;
|
||||||
|
|
||||||
$block = $values['value'];
|
$block = $values['value'];
|
||||||
if (!$this->isNextLineIndented()) {
|
if ($this->isNextLineIndented()) {
|
||||||
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
|
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ class Parser
|
|||||||
// hash
|
// hash
|
||||||
} elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
|
} elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
|
||||||
// if next line is less indented or equal, then it means that the current value is null
|
// if next line is less indented or equal, then it means that the current value is null
|
||||||
if ($this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
|
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
|
||||||
$data[$key] = null;
|
$data[$key] = null;
|
||||||
} else {
|
} else {
|
||||||
$c = $this->getRealCurrentLineNb() + 1;
|
$c = $this->getRealCurrentLineNb() + 1;
|
||||||
@ -482,18 +482,18 @@ class Parser
|
|||||||
private function isNextLineIndented()
|
private function isNextLineIndented()
|
||||||
{
|
{
|
||||||
$currentIndentation = $this->getCurrentLineIndentation();
|
$currentIndentation = $this->getCurrentLineIndentation();
|
||||||
$notEOF = $this->moveToNextLine();
|
$EOF = !$this->moveToNextLine();
|
||||||
|
|
||||||
while ($notEOF && $this->isCurrentLineEmpty()) {
|
while (!$EOF && $this->isCurrentLineEmpty()) {
|
||||||
$notEOF = $this->moveToNextLine();
|
$EOF = !$this->moveToNextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === $notEOF) {
|
if ($EOF) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if ($this->getCurrentLineIndentation() <= $currentIndentation) {
|
if ($this->getCurrentLineIndentation() > $currentIndentation) {
|
||||||
$ret = true;
|
$ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,6 +492,15 @@ yaml:
|
|||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyValue()
|
||||||
|
{
|
||||||
|
$input = <<<EOF
|
||||||
|
hash:
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$this->assertEquals(array('hash' => null), Yaml::parse($input));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class B
|
class B
|
||||||
|
Reference in New Issue
Block a user