Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93780 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3710 invoked from network); 4 Jun 2016 20:21:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 20:21:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=gen.work@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=gen.work@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.47 as permitted sender) X-PHP-List-Original-Sender: gen.work@gmail.com X-Host-Fingerprint: 209.85.215.47 mail-lf0-f47.google.com Received: from [209.85.215.47] ([209.85.215.47:33796] helo=mail-lf0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/DA-25194-46833575 for ; Sat, 04 Jun 2016 16:21:57 -0400 Received: by mail-lf0-f47.google.com with SMTP id s186so8467629lfs.1 for ; Sat, 04 Jun 2016 13:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eN8XkToYeJGQl59KX4SNIo81LF45IaVCOvn+6gra7Bo=; b=NbzsIG4ERDLoSwg7eGQb6pqJMGXfHFtmeyZg7npL4kJ17yjbYgGHSiLvCgrZOZnR66 BtBfEElx9055giHEx2YxfHL+iyrU0LVSlqVJ1aZJ72aOccImRjPeDMam/bIWFRvRnHHo MLL99+noSiTOPS/DZoBm63mU5b7rTpvGCg9piBMj89Vg66r7VxRyNNnD+be8ZsNgw0lz V9VeN5lMxWiW2VFZ8VMKUrbcLIcdpLpNNzYDif2gJMecN3DFdK7oW7gegNKVJ8GCXinb g6TTFkfPkJYI1SdzMCJXmMthFIFS/W2eyBHjLVuK5+d1rxFV4Y7Xpz+4TWGYBAnqPLRm yEdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eN8XkToYeJGQl59KX4SNIo81LF45IaVCOvn+6gra7Bo=; b=crNJLTJYP4W8MAxOdznSbnZTFuNv6rATCSTJz0W9fzk8yYRLHLcgDuIR6KA6NkhAJB XeJm1vBd+LXTl4EBMPlqtSzLnk9VERj6HpMj2I02Vg3i7ddPzS/AsWW2aZhwx9LiQQyk RymjpwVWQmYOXQJ/yUizmIpWHxeMNr7YNgEdMbtX4pLOImOBd9B+s+S9xZuZ78sxpx9c AdMhCkcn3r1+OuPSry2TTjam8l/AqoPLVS0+0+F0C9BSL9YnXri23euL7A17zT8TPuGU 7glOXOOB3WwakpzzBGkQ10ARowZXV58Swdu9LjJbxTXgL5fRGmNRUqRld8SVDmJkpi5V /jfQ== X-Gm-Message-State: ALyK8tJPi2sxfNBmyIzEmGcvrZywPrKPOBrTZbjrblmExciBjLoiqLLFALfsdFO9fH1dzqKfcZOFDKNTxBtsTQ== X-Received: by 10.25.170.140 with SMTP id t134mr2044578lfe.17.1465071713852; Sat, 04 Jun 2016 13:21:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.160.79 with HTTP; Sat, 4 Jun 2016 13:21:53 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Jun 2016 22:21:53 +0200 Message-ID: To: Jordi Boggiano Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1141146a1322ee0534799765 Subject: Re: [PHP-DEV] can't reflection on DateTime properties? From: gen.work@gmail.com (Eugene) --001a1141146a1322ee0534799765 Content-Type: text/plain; charset=UTF-8 On Sat, Jun 4, 2016 at 9:42 PM, Jordi Boggiano wrote: > 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 > > The simplified workaround is to cast a DateTime object to an array: https://3v4l.org/DESiq --001a1141146a1322ee0534799765--