diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 98fa3bf7518b..2dbc624ca7e9 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -80,7 +80,7 @@ public function parse($value) } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] - && preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P.+?))?\s*$#u', $values['value'], $matches) + && preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P.+?))?\s*$#u', $values['value'], $matches) ) { // this is a compact notation element, add to next block and parse $c = $this->getRealCurrentLineNb(); @@ -97,7 +97,7 @@ public function parse($value) $data[] = $this->parseValue($values['value']); } } - } else if (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { + } else if (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { $key = Inline::parseScalar($values['key']); if ('<<' === $key) { diff --git a/tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml b/tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml index 8eff31c60a28..4095159d972f 100644 --- a/tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml +++ b/tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml @@ -143,3 +143,17 @@ yaml: | 0123 php: | array('foo' => "0123\n") +--- +test: Document as a simple hash +brief: Document as a simple hash +yaml: | + { foo: bar } +php: | + array('foo' => 'bar') +--- +test: Document as a simple array +brief: Document as a simple array +yaml: | + [ foo, bar ] +php: | + array('foo', 'bar')