From 047212a439fb037bed7e032b0d49b35358c3c9a7 Mon Sep 17 00:00:00 2001 From: Pavel Volokitin Date: Fri, 12 Apr 2013 15:29:40 +0600 Subject: [PATCH] [Yaml] fixed handling an empty value --- src/Symfony/Component/Yaml/Parser.php | 6 +++--- src/Symfony/Component/Yaml/Tests/ParserTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index bafceb06c8..8dd9a23c47 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -102,7 +102,7 @@ class Parser $parser->refs =& $this->refs; $block = $values['value']; - if (!$this->isNextLineIndented()) { + if ($this->isNextLineIndented()) { $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); } @@ -174,7 +174,7 @@ class Parser // hash } 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 ($this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { + if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { $data[$key] = null; } else { $c = $this->getRealCurrentLineNb() + 1; @@ -493,7 +493,7 @@ class Parser } $ret = false; - if ($this->getCurrentLineIndentation() <= $currentIndentation) { + if ($this->getCurrentLineIndentation() > $currentIndentation) { $ret = true; } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 0e977a3ba4..4eea6d5308 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -492,6 +492,15 @@ yaml: EOF ); } + + public function testEmptyValue() + { + $input = <<assertEquals(array('hash' => null), Yaml::parse($input)); + } } class B