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


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to