Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93784 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10934 invoked from network); 4 Jun 2016 21:05:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 21:05:13 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.213.66 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.213.66 mail-vk0-f66.google.com Received: from [209.85.213.66] ([209.85.213.66:33331] helo=mail-vk0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/4C-25194-88243575 for ; Sat, 04 Jun 2016 17:05:13 -0400 Received: by mail-vk0-f66.google.com with SMTP id z65so410850vka.0 for ; Sat, 04 Jun 2016 14:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CLgtldBzvqm0WZ217semzH/5UkQQ543JL7XJt4BYsv0=; b=rxi+cF146kjlb3Kc1bXCbjIHqj2ApaFThbDCeY1ZSyTRC/ykvVAaF9SuXgBeWcA2Tb bKQWWyHmEbtBuH+GBlIaIRaW1nRJ6fgPkgY6obTVtWySX9gj9FDOuXKxXvX8ykxyb9oa 5dpN24YAWEq7r/W/HFACo45P+70drUzIh/HPqYxwlIsjzJMHkS5CT27vXd+ML3K8/mnG vEU0SjRGA2zJjqWg1zmyfdTP1sBzHShTJHfEckO+QbqQLIRat+khDbsFUMExDP5c/Nvq Yw8upeWWruT0BPIW3S28n+e8jkZgzMiYhJf8yDbxgb/ja2wIoKelXcx5ND+z1K1xDkWf EHMw== 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=CLgtldBzvqm0WZ217semzH/5UkQQ543JL7XJt4BYsv0=; b=lCLNBZp8GYuZ6vFqF6jny5E26ZJYIMSzCAnJD2xTLfUsMKyjkG4bWmw+kgmPcIvDg4 CplYR6r6+WTzhST88HRKVkhFQFuqPJBjkBiUr6yVXJOdImAA8DiCweZco3kg3dYJQul4 hz3+oo9lC0ZYmw0j8IXX4DpG8KrrMhtdTGu+iISVTmm9LFzg27nm2fpZxKA+Zmulv0yy VSsYjanwgmQ5qPGoEU/y5CJU6kttI6JBXlwmbc+RKJlmw8Yn42Vp+TUHGROmkIihEVrm xihgku+hVkWSTR6iw21Yn4ITcI7N41lWQUeoLeC1Yt5hdl3W4mvGRp/gp4aZ0hPXVy1W b1Hg== X-Gm-Message-State: ALyK8tJhMW9hE2cSzCMrSugbCJZjwZh6/SBHDw1MSc3R8Nr5wvttpk92HZroUqF8mRAIdVN/7+0lVQWHOzO2LA== X-Received: by 10.176.3.72 with SMTP id 66mr1433230uat.146.1465074310145; Sat, 04 Jun 2016 14:05:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.76.200 with HTTP; Sat, 4 Jun 2016 14:05:09 -0700 (PDT) In-Reply-To: <801c8df4-4f33-935b-5bee-ff73a0865433@gmail.com> References: <801c8df4-4f33-935b-5bee-ff73a0865433@gmail.com> Date: Sat, 4 Jun 2016 23:05:09 +0200 Message-ID: To: Stanislav Malyshev Cc: PHP internals Content-Type: multipart/alternative; boundary=001a113f2694d3b4c305347a310e Subject: Re: [PHP-DEV] can't reflection on DateTime properties? From: rasmus@mindplay.dk (Rasmus Schultz) --001a113f2694d3b4c305347a310e Content-Type: text/plain; charset=UTF-8 > In generic case, you can't have internal state of an object, that's why it's internal I know that things like internal state and read-only properties are possible for classes written in C, but those features aren't possible in PHP code - classes that behave this way are inconsistent with classes written in the language, and it becomes a problem in cases such as this. > If you need to serialize data, there are serialize/unserialize handlers for it. That is no help at all, when you're implementing a JSON serializer. You can see the class in question here: https://github.com/mindplay-dk/jsonfreeze/blob/master/mindplay/jsonfreeze/JsonSerializer.php Because DateTime does not behave like other classes, the only work-around is to explicitly handle DateTime with an if/instanceof-statement and handle that particular class explicitly. There are plenty of work-arounds - the point is that this class doesn't behave consistently with any other PHP class. On Sat, Jun 4, 2016 at 10:23 PM, Stanislav Malyshev wrote: > Hi! > > > The object clearly has properties corresponding to it's internal state, > but > > reflection doesn't seem to report them? > > Reflection reports defined properties, but classes can have dynamic > properties that are not pre-defined. var_dump also has a separate > handler, so the object can present different information to var_dump. > > > Also, what comes out of var_dump() appears to be something intended for > > human consumption? I'm guessing that's not the actual internal state of > the > > object - most likely the internal state consists of the "timezone_type" > and > > an integer timestamp? > > In generic case, you can't have internal state of an object, that's why > it's internal. If you need to serialize data, there are > serialize/unserialize handlers for it. > > -- > Stas Malyshev > smalyshev@gmail.com > --001a113f2694d3b4c305347a310e--