Re: can't reflection on DateTime properties?

From: Date: Sat, 04 Jun 2016 19:42:07 +0000
Subject: Re: can't reflection on DateTime properties?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-93778@lists.php.net to get a copy of this message
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

« previous php.internals (#93778) next »