title: Confusing class and method call in OpenCart
body: <p>I have a framework (OpenCart) Controller class (like: catalog/controller/product/product.php) the code looks like:</p>
  
  <pre><code>class ControllerProductProduct extends Controller {
      public function index() {
        //some code
        $this-&gt;response-&gt;setOutput($this-&gt;render());
        //some more code
      }
  }
  </code></pre>
  
  <p>there is an expression like <code>$this-&gt;response-&gt;setOutput($this-&gt;render());</code>. I know what this expression is used for, but I am pretty confused in how it works.</p>
  
  <p><code>$this</code> refers to current class i.e. <code>ControllerProductProduct</code>, it means <code>$this-&gt;response</code> object must exist in either <code>ControllerProductProduct</code> or its parent class <code>Controller</code>. But this is not the case. This object actually exists in a protected property of parent class <code>Controller</code> as <code>Controller::registry-&gt;data['response']-&gt;setOutput()</code>. So shouldn't it say like:</p>
  
  <pre><code>$this-&gt;registry-&gt;data['response']-&gt;setOutput();
  </code></pre>
  
  <p>instead of
      $this->response->setOutput();</p>
  
  <p>I am also giving a snippet of <code>Controller</code> class so you can have idea.</p>
  
  <pre><code>abstract class Controller {
      protected $registry;    
      //Other Properties
      public function __construct($registry) {
          $this-&gt;registry = $registry;
      }
      public function __get($key) {
          //get() returns registry-&gt;data[$key];
          return $this-&gt;registry-&gt;get($key);
      }
      public function __set($key, $value) {
          $this-&gt;registry-&gt;set($key, $value);
      }
      //Other methods
  }
  </code></pre>
  
  <p>I've no clue how this expression is working? Any idea how this is possible?</p>
  
  <p>Thanks.</p>