1--TEST-- 2Test that DatePeriod::__unserialize() can be called directly 3--FILE-- 4<?php 5 6$start = new DateTime("2022-07-14 00:00:00", new DateTimeZone("UTC")); 7$interval = new DateInterval('P1D'); 8$end = new DateTime("2022-07-16 00:00:00", new DateTimeZone("UTC")); 9$period = new DatePeriod($start, $interval, $end); 10 11$period->__unserialize( 12 [ 13 "start" => new DateTime("2022-07-14 12:00:00", new DateTimeZone("UTC")), 14 "end" => new DateTime("2022-07-16 12:00:00", new DateTimeZone("UTC")), 15 "current" => null, 16 "interval" => new DateInterval('P2D'), 17 "recurrences" => 2, 18 "include_start_date" => false, 19 "include_end_date" => true, 20 ] 21); 22 23var_dump($period); 24 25?> 26--EXPECTF-- 27object(DatePeriod)#%d (%d) { 28 ["start"]=> 29 object(DateTime)#%d (%d) { 30 ["date"]=> 31 string(26) "2022-07-14 12:00:00.000000" 32 ["timezone_type"]=> 33 int(3) 34 ["timezone"]=> 35 string(3) "UTC" 36 } 37 ["current"]=> 38 NULL 39 ["end"]=> 40 object(DateTime)#%d (%d) { 41 ["date"]=> 42 string(26) "2022-07-16 12:00:00.000000" 43 ["timezone_type"]=> 44 int(3) 45 ["timezone"]=> 46 string(3) "UTC" 47 } 48 ["interval"]=> 49 object(DateInterval)#%d (%d) { 50 ["y"]=> 51 int(0) 52 ["m"]=> 53 int(0) 54 ["d"]=> 55 int(2) 56 ["h"]=> 57 int(0) 58 ["i"]=> 59 int(0) 60 ["s"]=> 61 int(0) 62 ["f"]=> 63 float(0) 64 ["invert"]=> 65 int(0) 66 ["days"]=> 67 bool(false) 68 ["from_string"]=> 69 bool(false) 70 } 71 ["recurrences"]=> 72 int(2) 73 ["include_start_date"]=> 74 bool(false) 75 ["include_end_date"]=> 76 bool(true) 77} 78