consistently parse omitted keys as the colon

This commit is contained in:
Christian Flothmann 2017-02-17 11:55:39 +01:00
parent fb8abdc9fc
commit e2ebecc0cb
2 changed files with 7 additions and 2 deletions

View File

@ -459,11 +459,11 @@ class Inline
// key
$key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
if (false === $i = strpos($mapping, ':', $i)) {
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
break;
}
if (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true)) {
if (':' !== $key && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
@trigger_error('Using a colon that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}" is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
}

View File

@ -686,4 +686,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
}
public function testOmittedMappingKeyIsParsedAsColon()
{
$this->assertSame(array(':' => 'foo'), Inline::parse('{: foo}'));
}
}