1--TEST-- 2DatePeriod invalid serialization data 3--FILE-- 4<?php 5$propertySets = [ 6 /* Two correct elements */ 7 [ 8 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 9 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => true, 'include_end_date' => true, 10 ], 11 [ 12 'start' => null, 'end' => null, 'current' => null, 13 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => false, 'include_end_date' => false, 14 ], 15 /* Error situations */ 16 [ 17 'start' => "2023-01-13 12:29:30", 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 18 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => true, 'include_end_date' => true, 19 ], 20 [ 21 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => "2023-01-16 16:49:29", 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 22 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => true, 'include_end_date' => true, 23 ], 24 [ 25 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => "2023-01-15 00:00:00", 26 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => true, 'include_end_date' => true, 27 ], 28 [ 29 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 30 'interval' => "tomorrow", 'recurrences' => 1, 'include_start_date' => true, 'include_end_date' => true, 31 ], 32 [ 33 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 34 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => -1, 'include_start_date' => true, 'include_end_date' => true, 35 ], 36 [ 37 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 38 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => "true", 'include_end_date' => true, 39 ], 40 [ 41 'start' => new \DateTimeImmutable("2023-01-13 12:29:30"), 'end' => new \DateTimeImmutable("2023-01-16 16:49:29"), 'current' => new \DateTimeImmutable("2023-01-15 00:00:00"), 42 'interval' => DateInterval::createFromDateString("tomorrow"), 'recurrences' => 1, 'include_start_date' => true, 'include_end_date' => "true", 43 ], 44]; 45 46foreach( $propertySets as $propertySet ) 47{ 48 try { 49 $d = DatePeriod::__set_state( $propertySet ); 50 echo "OK\n"; 51 } catch (\Error $e) { 52 echo $e::class, ': ', $e->getMessage(), "\n"; 53 } 54} 55?> 56--EXPECT-- 57OK 58OK 59Error: Invalid serialization data for DatePeriod object 60Error: Invalid serialization data for DatePeriod object 61Error: Invalid serialization data for DatePeriod object 62Error: Invalid serialization data for DatePeriod object 63Error: Invalid serialization data for DatePeriod object 64Error: Invalid serialization data for DatePeriod object 65Error: Invalid serialization data for DatePeriod object 66