title: PHP inheritance: child class overriding parent variable/property for use in constructor
body: <p>I have an (abstract) parent class supposed to provide functionality during construction. Child classes can override properties used in the constructor:</p>
  
  <pre><code>class Parent extends MiddlewareTest
  {
      // abstract channel properties
      protected $title = NULL;
      protected $type = NULL;
      protected $resolution = NULL;
  
      function __construct() {
          parent::__construct();
  
          $this-&gt;uuid = $this-&gt;createChannel($this-&gt;title, $this-&gt;type, $this-&gt;resolution);
      }
  }
  
  class Child extends Parent
  {
      // channel properties
      protected $title = 'Power';
      protected $type = 'power';
      protected $resolution = 1000;
  }
  </code></pre>
  
  <p>Problem is that the overridden properties are not used when <code>Child::__construct()</code> which is not overridden runs (<code>$this-&gt;createChannel</code> is called with <code>NULL</code> parameters).</p>
  
  <p>Is this possible in PHP or will I have to resort to overriding child constructors each time to provide the desired functionality?</p>
  
  <p>Note: I saw <a href="https://stackoverflow.com/questions/17862783/properties-shared-between-child-and-parents-class-in-php">Properties shared between child and parents class in php</a> but this is different as the child properties are not assigned in the constructor but by definition.</p>
  
  <p><strong>Update</strong></p>
  
  <p>It turns out my test case was faulty. As the MiddlewareTest was based on SimpleTest unit test case, SimpleTest had actually- what I didn't realize- by it's autorun instantiated the Parent class itself which was never intented. Fixed by making the Parent class abstract.</p>
  
  <p>Lessons learned: build a clean test case and actually run it before crying for help.</p>