Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2ebecc

Browse filesBrowse files
committed
consistently parse omitted keys as the colon
1 parent fb8abdc commit e2ebecc
Copy full SHA for e2ebecc

File tree

Expand file treeCollapse file tree

2 files changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-2
lines changed

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
459459
// key
460460
$key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
461461

462-
if (false === $i = strpos($mapping, ':', $i)) {
462+
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
463463
break;
464464
}
465465

466-
if (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true)) {
466+
if (':' !== $key && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
467467
@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);
468468
}
469469

‎src/Symfony/Component/Yaml/Tests/InlineTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,4 +686,9 @@ public function testVeryLongQuotedStrings()
686686

687687
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
688688
}
689+
690+
public function testOmittedMappingKeyIsParsedAsColon()
691+
{
692+
$this->assertSame(array(':' => 'foo'), Inline::parse('{: foo}'));
693+
}
689694
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.