bug #20291 [Yaml] Fix 7.1 compat (nicolas-grekas)
This PR was merged into the 3.1 branch.
Discussion
----------
[Yaml] Fix 7.1 compat
| Q | A
| ------------- | ---
| Branch? | 3.1
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Should make CI green again with PHP 7.1 RC4.
Commits
-------
89b78f2
[Yaml] Fix 7.1 compat
This commit is contained in:
commit
c3b96908e7
@ -606,7 +606,10 @@ class Inline
|
||||
return (float) str_replace(',', '', $scalar);
|
||||
case preg_match(self::getTimestampRegex(), $scalar):
|
||||
if (Yaml::PARSE_DATETIME & $flags) {
|
||||
return new \DateTime($scalar, new \DateTimeZone('UTC'));
|
||||
$date = new \DateTime($scalar);
|
||||
$date->setTimeZone(new \DateTimeZone('UTC'));
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
$timeZone = date_default_timezone_get();
|
||||
|
@ -507,7 +507,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
$expected->setTime($hour, $minute, $second);
|
||||
@$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
|
||||
|
||||
$this->assertEquals($expected, Inline::parse($yaml, Yaml::PARSE_DATETIME));
|
||||
}
|
||||
@ -515,9 +515,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
public function getTimestampTests()
|
||||
{
|
||||
return array(
|
||||
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43),
|
||||
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43),
|
||||
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43),
|
||||
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1),
|
||||
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1),
|
||||
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1),
|
||||
'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0),
|
||||
);
|
||||
}
|
||||
@ -530,7 +530,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
$expected->setTime($hour, $minute, $second);
|
||||
@$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
|
||||
|
||||
$expectedNested = array('nested' => array($expected));
|
||||
$yamlNested = "{nested: [$yaml]}";
|
||||
|
Reference in New Issue
Block a user