On 04/06/2016 20:36, Rasmus Schultz wrote:
I wrote a library that can serialize/unserialize PHP object graphs to JSON
data.
Somebody reported it doesn't work on the DateTime class.
Does this deliberately not work?
$date = new DateTime();
var_dump($date);
outputs:
object(DateTime)#1 (3) {
["date"]=>
string(19) "2016-06-04 19:30:19"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
however, this...
$reflection = new ReflectionClass('DateTime');
var_dump($reflection->getProperties());
outputs:
array(0) {
}
The object clearly has properties corresponding to it's internal state, but
reflection doesn't seem to report them?
I can't tell you why it acts like this, but in case you are looking for
a workaround: https://3v4l.org/V5cfl
Cheers
--
Jordi Boggiano
@seldaek - http://seld.be
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php