title: Anonymous Function/Closure and using self:: or static::
body: <p>I am working with anonymous functions where I am creating anonymous function outside of the object, and then adding it to an object later in which it will be used with __callStatic magic function. The closures that are being added to contain methods from the parent class. I am wondering if I would be able to call those methods from the closure?</p>
  
  <p>Right now I get this error:</p>
  
  <pre><code>EmptyObject::addMethod('open', function(){
      if (static::_hasAdapter(get_class(), __FUNCTION__))
              return self::_callAdapter(get_class(), __FUNCTION__, $details);
  
      echo '&lt;p&gt;You have mail!&lt;/p&gt;';
  });
  </code></pre>
  
  <p>throws this error:</p>
  
  <blockquote>
    <p>Fatal error: Cannot access static:: when no class scope is active in </p>
  </blockquote>
  
  <p>And</p>
  
  <pre><code>//Add the functions
  EmptyObject::addMethod('open', function(){
      if (EmptyObject::_hasAdapter('EmptyObject', __FUNCTION__))
              return EmptyObject::_callAdapter('EmptyObject', __FUNCTION__, $details);
  
      echo '&lt;p&gt;You have mail!&lt;/p&gt;';
  });
  </code></pre>
  
  <p>throw this error because the method is protected</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'BadMethodCallException' with message 'Method '_hasAdapter' was not found in class EmptyObject' </p>
  </blockquote>