@@ -5,6 +5,7 @@ date.timezone=UTC
55--FILE--
66<?php
77$ now = new DateTimeImmutable ();
8+ $ simpleInterval = new DateInterval ("P2D " );
89
910$ date = (new ReflectionClass (DateTime::class))->newInstanceWithoutConstructor ();
1011try {
2021 echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
2122}
2223
24+ $ date = (new ReflectionClass (DateTime::class))->newInstanceWithoutConstructor ();
25+ $ dateperiod = (new ReflectionClass (DatePeriod::class))->newInstanceWithoutConstructor ();
26+ $ dateinterval = (new ReflectionClass (DateInterval::class))->newInstanceWithoutConstructor ();
27+ try {
28+ $ dateperiod ->__unserialize (['start ' => $ date ]);
29+ } catch (Error $ e ) {
30+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
31+ }
32+
33+ try {
34+ $ dateperiod ->__unserialize (['start ' => $ now , 'end ' => $ date ]);
35+ } catch (Error $ e ) {
36+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
37+ }
38+
39+ try {
40+ $ dateperiod ->__unserialize (['start ' => $ now , 'end ' => $ now , 'current ' => $ date ]);
41+ } catch (Error $ e ) {
42+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
43+ }
44+
45+ try {
46+ $ dateperiod ->__unserialize (['start ' => $ now , 'end ' => $ now , 'current ' => $ now , 'interval ' => $ dateinterval ]);
47+ } catch (Error $ e ) {
48+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
49+ }
50+
51+ try {
52+ $ dateperiod ->__unserialize ([
53+ 'start ' => $ now , 'end ' => $ now , 'current ' => $ now , 'interval ' => $ simpleInterval ,
54+ 'recurrences ' => 2 , 'include_start_date ' => true , 'include_end_date ' => true ,
55+ ]);
56+ echo "DatePeriod::__unserialize: SUCCESS \n" ;
57+ } catch (Error $ e ) {
58+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
59+ }
2360echo "OK \n" ;
2461?>
2562--EXPECT--
2663Error: The DateTimeInterface object has not been correctly initialized by its constructor
2764Error: The DateTimeInterface object has not been correctly initialized by its constructor
65+ Error: Invalid serialization data for DatePeriod object
66+ Error: Invalid serialization data for DatePeriod object
67+ Error: Invalid serialization data for DatePeriod object
68+ Error: Invalid serialization data for DatePeriod object
69+ DatePeriod::__unserialize: SUCCESS
2870OK
0 commit comments