Skip to content

Commit 0d357b5

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Form] fix support for years outside of the 32b range on x86 arch CS fix remove duplicate test Add an upgrade note about the removal of Serializable [SecurityBundle] Don't register deprecated listeners with authenticator manager enabled
2 parents 23727d8 + ad4cce9 commit 0d357b5

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

Inline.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -673,17 +673,22 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
673673
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
674674
return (float) str_replace('_', '', $scalar);
675675
case Parser::preg_match(self::getTimestampRegex(), $scalar):
676+
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
677+
$time = new \DateTime($scalar, new \DateTimeZone('UTC'));
678+
676679
if (Yaml::PARSE_DATETIME & $flags) {
677-
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
678-
return new \DateTime($scalar, new \DateTimeZone('UTC'));
680+
return $time;
679681
}
680682

681-
$timeZone = date_default_timezone_get();
682-
date_default_timezone_set('UTC');
683-
$time = strtotime($scalar);
684-
date_default_timezone_set($timeZone);
683+
try {
684+
if (false !== $scalar = $time->getTimestamp()) {
685+
return $scalar;
686+
}
687+
} catch (\ValueError $e) {
688+
// no-op
689+
}
685690

686-
return $time;
691+
return $time->format('U');
687692
}
688693
}
689694

Tests/InlineTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public function getTestsForParse()
326326
['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)],
327327
['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)],
328328
['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)],
329-
['1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)],
329+
['1730-10-30T02:59:43Z', \PHP_INT_SIZE === 4 ? '-7547547617' : gmmktime(2, 59, 43, 10, 30, 1730)],
330330

331331
['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''],
332332
["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''],
@@ -397,7 +397,7 @@ public function getTestsForParseWithMapObjects()
397397
['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)],
398398
['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)],
399399
['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)],
400-
['1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)],
400+
['1730-10-30T02:59:43Z', \PHP_INT_SIZE === 4 ? '-7547547617' : gmmktime(2, 59, 43, 10, 30, 1730)],
401401

402402
['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''],
403403
["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''],

0 commit comments

Comments
 (0)