[YAML] Fixed parsing problem with nested DateTime lists
This commit is contained in:
parent
33636c7330
commit
4f13a76ce8
@ -397,7 +397,7 @@ class Inline
|
|||||||
$value = self::parseScalar($sequence, $flags, array(',', ']'), array('"', "'"), $i, true, $references);
|
$value = self::parseScalar($sequence, $flags, array(',', ']'), array('"', "'"), $i, true, $references);
|
||||||
|
|
||||||
// the value can be an array if a reference has been resolved to an array var
|
// the value can be an array if a reference has been resolved to an array var
|
||||||
if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) {
|
if (!is_array($value) && !$value instanceof \DateTimeInterface && !$isQuoted && false !== strpos($value, ': ')) {
|
||||||
// embedded mapping?
|
// embedded mapping?
|
||||||
try {
|
try {
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
|
@ -524,6 +524,22 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getTimestampTests
|
||||||
|
*/
|
||||||
|
public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second)
|
||||||
|
{
|
||||||
|
$expected = new \DateTime($yaml);
|
||||||
|
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||||
|
$expected->setDate($year, $month, $day);
|
||||||
|
$expected->setTime($hour, $minute, $second);
|
||||||
|
|
||||||
|
$expectedNested = array('nested' => array($expected));
|
||||||
|
$yamlNested = "{nested: [$yaml]}";
|
||||||
|
|
||||||
|
$this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getDateTimeDumpTests
|
* @dataProvider getDateTimeDumpTests
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user