title: Static Properties in PHP7 Anonymous Classes
body: <p>I'm working on an ORM for one of my projects, and I'm trying to avoid unnecessarily "hardcoding" the classes by using anonymous classes to extend the default functionality of the base, abstract Model. </p>
  
  <p>Right now, all queries are based on a static property <code>$table_name</code> that I'd like to override in the anonymous class. However, when I try to do this, all other instances of the anonymous class receive the same value, although ideally they would get their own distinct values. I would just use a non-static property in the class instead, but there are static functions that use the static property.</p>
  
  <p>The options that I see are to</p>
  
  <ol>
  <li>Manually create each class and hardcode the tablename for each model</li>
  <li>Rework the code to use non-static properties and parameters</li>
  </ol>
  
  <p>Both of these solutions work, but don't seem to be as elegant as I'd like them to be. Any suggestions?</p>
  
  <p>Here is an example code sample</p>
  
  <p>Model class</p>
  
  <pre><code>&lt;?php
  class Model{
  protected static $table_name;
  public static function query_table(){
      [...use static::$table_name]
  }
  </code></pre>
  
  <p>Extending anonymous class</p>
  
  <pre><code>(new class() extends TableModel {
  protected static $table_name         = null;
  
  public function setTableName($table_name) {
      static::$table_name = $table_name;
  }
  });
  </code></pre>