title: php child class constructor called with parent object as parameter
body: <p>I am not that good yet on php syntax, so here is my question:</p>
  
  <p>I have a class Foo.</p>
  
  <p>Class Bar extends Foo.</p>
  
  <p>I want to make a constructor for Bar that is called with an instance of class Foo as parameter, and make an instance of Bar that looks just like the instance of class Foo.</p>
  
  <p>It seems I have to do this because Foo is a class in a WordPress plugin. I am writing a plugin to go on top of the original plugin, and in the filter I can add to, I get the Foo object. </p>
  
  <p>I am open to doing this in the "right" way, if I can just learn the "right" way to do it.</p>
  
  <p>so:</p>
  
  <pre><code>class Foo {      // in the original plugin
     public function __construct() {
         &lt;do some stuff&gt;
     }
  }
  
  class Bar extends Foo {     // in my plugin to extend the original plugin
     public function __construct($myFooObject) {
        &lt;I want: $this = $myFooObject; but it doesnt work&gt;
        &lt;do some stuff special to Bar&gt;
     }
  }
  </code></pre>