consistently parse omitted keys as the colon
This commit is contained in:
parent
fb8abdc9fc
commit
e2ebecc0cb
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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}'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user