title: Getting the name of a child class in the parent class (static context)
body: <p>I'm building an ORM library with reuse and simplicity in mind; everything goes fine except that I got stuck by a stupid inheritance limitation. Please consider the code below:</p>
  
  <pre><code>class BaseModel {
      /*
       * Return an instance of a Model from the database.
       */
      static public function get (/* varargs */) {
          // 1. Notice we want an instance of User
          $class = get_class(parent); // value: bool(false)
          $class = get_class(self);   // value: bool(false)
          $class = get_class();       // value: string(9) "BaseModel"
          $class =  __CLASS__;        // value: string(9) "BaseModel"
  
          // 2. Query the database with id
          $row = get_row_from_db_as_array(func_get_args());
  
          // 3. Return the filled instance
          $obj = new $class();
          $obj-&gt;data = $row;
          return $obj;
      }
  }
  
  class User extends BaseModel {
      protected $table = 'users';
      protected $fields = array('id', 'name');
      protected $primary_keys = array('id');
  }
  class Section extends BaseModel {
      // [...]
  }
  
  $my_user = User::get(3);
  $my_user-&gt;name = 'Jean';
  
  $other_user = User::get(24);
  $other_user-&gt;name = 'Paul';
  
  $my_user-&gt;save();
  $other_user-&gt;save();
  
  $my_section = Section::get('apropos');
  $my_section-&gt;delete();
  </code></pre>
  
  <p>Obviously, this is not the behavior I was expecting (although the actual behavior also makes sense).. So my question is if you guys know of a mean to get, in the parent class, the name of child class.</p>