1--TEST--
2Test __set_state magic method for recreating a DateTimeImmutable object
3--CREDITS--
4Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
5--FILE--
6<?php
7
8$datettimeObject = new DateTimeImmutable('2017-10-06 23:30:00', new DateTimezone('UTC'));
9
10$datetimeState = var_export($datettimeObject, true);
11
12eval("\$datetimeObjectNew = {$datetimeState};");
13
14var_dump($datetimeObjectNew);
15
16?>
17--EXPECTF--
18object(DateTimeImmutable)#%d (3) {
19  ["date"]=>
20  string(26) "2017-10-06 23:30:00.000000"
21  ["timezone_type"]=>
22  int(3)
23  ["timezone"]=>
24  string(3) "UTC"
25}
26