8000 [Yaml] Fix 7.1 compat · src-run/symfony@89b78f2 · GitHub
[go: up one dir, main page]

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 89b78f2

Browse files
[Yaml] Fix 7.1 compat
1 parent 57f8d1e commit 89b78f2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, $str
317317
}
318318

319319
if ($output && '%' === $output[0]) {
320-
@trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.' , $output), E_USER_DEPRECATED);
320+
@trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output), E_USER_DEPRECATED);
321321
}
322322

323323
if ($evaluate) {
@@ -606,7 +606,10 @@ private static function evaluateScalar($scalar, $flags, $references = array())
606606
return (float) str_replace(',', '', $scalar);
607607
case preg_match(self::getTimestampRegex(), $scalar):
608608
if (Yaml::PARSE_DATETIME & $flags) {
609-
return new \DateTime($scalar, new \DateTimeZone('UTC'));
609+
$date = new \DateTime($scalar);
610+
$date->setTimeZone(new \DateTimeZone('UTC'));
611+
612+
return $date;
610613
}
611614

612615
$timeZone = date_default_timezone_get();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,17 @@ public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $
507507
$expected = new \DateTime($yaml);
508508
$expected->setTimeZone(new \DateTimeZone('UTC'));
509509
$expected->setDate($year, $month, $day);
510-
$expected->setTime($hour, $minute, $second);
510+
@$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
511511

512512
$this->assertEquals($expected, Inline::parse($yaml, Yaml::PARSE_DATETIME));
513513
}
514514

515515
public function getTimestampTests()
516516
{
517517
return array(
518-
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43),
519-
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43),
520-
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43),
518+
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1),
519+
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1),
520+
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1),
521521
'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0),
522522
);
523523
}
@@ -530,7 +530,7 @@ public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $mont
530530
$expected = new \DateTime($yaml);
531531
$expected->setTimeZone(new \DateTimeZone('UTC'));
532532
$expected->setDate($year, $month, $day);
533-
$expected->setTime($hour, $minute, $second);
533+
@$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
534534

535535
$expectedNested = array('nested' => array($expected));
536536
$yamlNested = "{nested: [$yaml]}";

0 commit comments

Comments
 (0)
0