title: How to get the hierarchical order of properties with get_object_vars?
body: <p>I have some classes that extend each other, each time adding more properties.</p>
  
  <p>Now I need to get a list of all properties of a class, but in the <em>order</em> that they were declared, with the properties of the parent class first.</p>
  
  <p>For example :</p>
  
  <pre><code>class foo {
      public $a = 1;
      public $c = 2;
      public $d = 3;
  }
  
  class foo2 extends foo {
      public $b = 4;
  }
  
  $test = new foo2;
  
  var_dump(get_object_vars($test));
  </code></pre>
  
  <p>This gives :</p>
  
  <pre><code>array(4) { ["b"]=&gt; int(4) ["a"]=&gt; int(1) ["c"]=&gt; int(2) ["d"]=&gt; int(3) } 
  </code></pre>
  
  <p>but I want :</p>
  
  <pre><code>array(4) { ["a"]=&gt; int(1) ["c"]=&gt; int(2) ["d"]=&gt; int(3) ["b"]=&gt; int(4) } 
  </code></pre>
  
  <p>Is there any way this could be achieved?</p>
  
  <p><em><strong>UPDATE:</em></strong>
  The reason I need this, is because I'm converting a file that uses the STEP (EXPRESS ISO 10303-21) format (and back!). (See this for more information : <a href="http://en.wikipedia.org/wiki/ISO_10303-21" rel="nofollow">http://en.wikipedia.org/wiki/ISO_10303-21</a>)  This format is some kind of serialized objects structure. I recreated all object classes in PHP, but since in STEP the order of the properties is crucial, I need the exact same order of the properties.</p>