title: My mixin class is causing my classes to become static - PHP
body: <p>So this is my mixin class:</p>
  
  <pre><code>class AisisCore_Loader_Mixins {
  
      private $_classes;
  
      private $_class_objects = array();
  
      private $_methods = array();
  
      public function __construct(){
          $this-&gt;init();
      }
  
      public function init(){}
  
      public function setup($class){
          if(!is_array($class)){
              throw new AisisCore_Loader_LoaderException('Object passed in must be of type $class_name=&gt;$params.');
          }
  
          $this-&gt;_classes = $class;
          $this-&gt;get_class_objects();
          $this-&gt;get_methods();    
      }
  
      public function get_class_objects(){
          foreach($this-&gt;_classes as $class_name=&gt;$params){
              $object = new ReflectionClass($class_name);
              $object_name = get_class($object);
              $this-&gt;_class_objects[$object-&gt;name] = $object-&gt;newInstanceArgs($params);
          }
      }
  
      public function get_methods(){ 
          foreach($this-&gt;_class_objects as $class_object_name =&gt; $class_object){
              $this-&gt;_methods[$class_object_name] = get_class_methods($class_object);
          }
  
          return $this-&gt;_methods;
      }
  
      public function __call($name, $param = null){
          foreach($this-&gt;_methods as $class_name=&gt;$methods){
              foreach($methods as $method){
                  if($name === $method){
                      return $this-&gt;isParam($class_name, $method, $param);
                  }
              }
          }
  
          throw new AisisCore_Loader_LoaderException("Method: " .$name. 
                              " does not exist or it's access is not public");
      }
  
      private function isParam($class_name, $method, $param){
          if($param != null){
              call_user_func(array($class_name, $method), $param);
          }else{
              call_user_func(array($class_name, $method));
          }        
      }
  }
  </code></pre>
  
  <p>Pretty simple stuff, load a set of classes, allow you to call their functions and so on, but we have a new issue. It seems that classes passed into this are instantiated as static, thus their methods cannot use <code>$this-&gt;</code> they are resorted to using <code>self::</code> which is wrong.</p>
  
  <p>Lets see an example of how this all works:</p>
  
  <pre><code>class BaseBridge extends AisisCore_Loader_Mixins{
  
      public function __construct(){ 
          parent::construct();
  
          $this-&gt;setup(array('ClassB' =&gt; array()));
      }
  }
  </code></pre>
  
  <p>Lets Define <code>ClassB</code></p>
  
  <pre><code>class ClassB{
  
      public function __construct(){}
  
      public function some_method(){
          $this-&gt;_some_private_method();
      }
  
      private function _some_private_method(){}
  }
  </code></pre>
  
  <p>Pretty basic stuff, so lets hook it all up in <code>ClassA</code></p>
  
  <pre><code>class ClassA extends BaseBridge{
  
      public function __construct(){ 
          parent::__construct(); 
          $this-&gt;some_method();
      }
  } 
  </code></pre>
  
  <p><strong>Quick Review:</strong> We have a core class, <code>ClassA</code> which extends <code>BaseBridge</code> which is our bridge class between one or more (meant to be used with more) classes that <code>ClassA</code> extends from. In this case were only extending from <code>ClassB</code> for simplicity.</p>
  
  <p><strong>Whats the issue?</strong> See, how in <code>ClassB</code>, were doing: <code>$this-&gt;_some_private_method();</code> ya that's going to epically and catastrophically fail. <em>Why?</em> because I get the error: <code>Using $this when not in object context</code> which makes me so confused, so I change it to: <code>self::$_some_private_method();</code> and it works like a charm.</p>
  
  <p>Why? and what do I have to change or fix to make it so that <code>$this</code> can be used in a class being instantiated through the mixin class?</p>