title: PHP: using var_export with extended classes?
body: <p>In PHP I'm trying to use <code>var_export</code> but I cannot get it to work with an extended class:</p>
  
  <pre><code>class BaseClass {
      public $a = 1;
  
      public static function __set_state($array) {
        //is it possible to get the classname of the extended class here?
        $obj = new BaseClass();
  
        foreach($array as $k =&gt; $v) {
          $obj-&gt;$k = $v;
        }
  
        return $obj;
      }
  }
  
  class ExtendedClass extends BaseClass {
      public $b = 2;
  }
  
  $object = new ExtendedClass();
  
  var_dump($object);
  
  $serialized_object = var_export($object, true);
  eval('$object2 = ' . $serialized_object. ';'); 
  
  echo "&lt;br/&gt;";
  var_dump($object2);
  </code></pre>
  
  <p>$object2 will then be of class <code>BaseClass</code> instead of <code>ExtendedClass</code> !</p>
  
  <p>I have a few thousand classes that extend from a base class, so making a <code>__set_state</code> method for every class is not really an option. </p>
  
  <p>Is it somehow possible in <code>__set_state</code> to get the classname of the extended class ?</p>