Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26950 invoked from network); 9 Sep 2012 07:51:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Sep 2012 07:51:46 -0000 Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=brianofish@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: brianofish@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:61095] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/22-06600-09A4C405 for ; Sun, 09 Sep 2012 03:51:45 -0400 Received: by eaao11 with SMTP id o11so360269eaa.29 for ; Sun, 09 Sep 2012 00:51:40 -0700 (PDT) Received: by 10.204.128.196 with SMTP id l4mr3347438bks.21.1347177100551; Sun, 09 Sep 2012 00:51:40 -0700 (PDT) Received: from [192.168.178.32] ([213.135.15.139]) by mx.google.com with ESMTPS id hs2sm4857058bkc.1.2012.09.09.00.51.39 (version=SSLv3 cipher=OTHER); Sun, 09 Sep 2012 00:51:39 -0700 (PDT) To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Date: Sun, 09 Sep 2012 09:51:37 +0200 Message-ID: <1347177097.6077.82.camel@lat17.home.bof.de> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 Content-Transfer-Encoding: 7bit Subject: get_class_vars() returned information ORDER From: php@bof.de (Patrick Schaaf) Hi, I'm curious whether the ORDER of the class properties returned by get_class_vars(), is in some way guaranteed. I do not find mention of it in the documentation. I'm especially interested in the order of static class variables returned. Testing, using PHP 5.4.6, I find that there seems to be a stable order, which suits my reasons for looking into this quite nicely. Here is what I find: - static properties defined directly in the class itself come first, in definition (source) order - static properties defined directly in parent classes come next, in definition order of their respective sources, and going up the class tree. So grandparent properties come after parent properties - static properties contributed by traits, all come AFTER the properties from the class source itself, including all ancestors - static properties contributed by a single trait come in definition (source) order of that trait definition - with static properties from several traits, those of the HIGHEST class in the inheritance tree some first, and those from the class under inspection come last. This is exactly the opposite order of what happens with properties from the classes themselves. As it happens, the ordering I find for static properties contributed by traits, is exactly what I was looking for. But is it guaranteed, or could such a guarantee be made? best regards Patrick