Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc473504

Browse files
committed
parse omitted inlined mapping values as null
1 parent36dacbc commitc473504

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

‎src/Symfony/Component/Yaml/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
3.3.0
55
-----
66

7+
* Omitted mapping values will be parsed as`null`.
8+
79
* Omitting the key of a mapping is deprecated and will throw a`ParseException` in Symfony 4.0.
810

911
* Added support for dumping empty PHP arrays as YAML sequences:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i
318318
if (preg_match('/[ \t]+#/',$output,$match,PREG_OFFSET_CAPTURE)) {
319319
$output =substr($output,0,$match[0][1]);
320320
}
321-
}elseif (preg_match('/^(.+?)('.implode('|',$delimiters).')/',substr($scalar,$i),$match)) {
321+
}elseif (preg_match('/^(.*?)('.implode('|',$delimiters).')/',substr($scalar,$i),$match)) {
322322
$output =$match[1];
323323
$i +=strlen($output);
324324
}else {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,20 @@ public function testOmittedMappingKeyIsParsedAsColon()
702702
{
703703
$this->assertSame(array(':' =>'foo'), Inline::parse('{: foo}'));
704704
}
705+
706+
/**
707+
* @dataProvider getTestsForNullValues
708+
*/
709+
publicfunctiontestParseMissingMappingValueAsNull($yaml,$expected)
710+
{
711+
$this->assertSame($expected, Inline::parse($yaml));
712+
}
713+
714+
publicfunctiongetTestsForNullValues()
715+
{
716+
returnarray(
717+
'null before closing curly brace' =>array('{foo:}',array('foo' =>null)),
718+
'null before comma' =>array('{foo:, bar: baz}',array('foo' =>null,'bar' =>'baz')),
719+
);
720+
}
705721
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp