Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f10a206

Browse files
[VarExporter] Fix exporting DateTime objects on PHP 8.2
1 parent aca1d8f commit f10a206

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/Symfony/Component/VarExporter/Internal/Exporter.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
111111
} elseif ($value instanceof \Serializable
112112
|| $value instanceof \__PHP_Incomplete_Class
113113
|| $value instanceof \DatePeriod
114-
|| (\PHP_VERSION_ID >= 80200 && (
115-
$value instanceof \DateTimeInterface
116-
|| $value instanceof \DateTimeZone
117-
|| $value instanceof \DateInterval
118-
))
119114
) {
120115
++$objectsCount;
121116
$objectsPool[$value] = [$id = \count($objectsPool), serialize($value), [], 0];
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

33
return \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
4-
$o = \Symfony\Component\VarExporter\Internal\Registry::unserialize([], [
5-
'O:8:"DateTime":3:{s:4:"date";s:26:"1970-01-01 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}',
6-
'O:17:"DateTimeImmutable":3:{s:4:"date";s:26:"1970-01-01 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}',
7-
'O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:12:"Europe/Paris";}',
8-
'O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:7;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";i:7;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}',
4+
$o = \Symfony\Component\VarExporter\Internal\Registry::unserialize([
5+
clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['DateTime'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('DateTime')),
6+
clone ($p['DateTimeImmutable'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('DateTimeImmutable')),
7+
clone ($p['DateTimeZone'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('DateTimeZone')),
8+
], [
9+
3 => 'O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:7;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";i:7;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}',
910
'O:10:"DatePeriod":6:{s:5:"start";O:8:"DateTime":3:{s:4:"date";s:26:"2009-10-11 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:12:"Europe/Paris";}s:7:"current";N;s:3:"end";N;s:8:"interval";O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:7;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";i:7;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}s:11:"recurrences";i:5;s:18:"include_start_date";b:1;}',
1011
]),
1112
null,
@@ -17,5 +18,20 @@
1718
$o[3],
1819
$o[4],
1920
],
20-
[]
21+
[
22+
[
23+
'date' => '1970-01-01 00:00:00.000000',
24+
'timezone_type' => 1,
25+
'timezone' => '+00:00',
26+
],
27+
-1 => [
28+
'date' => '1970-01-01 00:00:00.000000',
29+
'timezone_type' => 1,
30+
'timezone' => '+00:00',
31+
],
32+
-2 => [
33+
'timezone_type' => 3,
34+
'timezone' => 'Europe/Paris',
35+
],
36+
]
2137
);

0 commit comments

Comments
 (0)