title: How to call the __invoke method of a member variable inside a class
body: <p>PHP 5.4.5, here.  I'm trying to invoke an object which is stored as a member of some other object.  Like this (very roughly)</p>
  
  <pre><code>class A {
      function __invoke () { ... }
  }
  
  class B {
      private a = new A();
   ...
      $this-&gt;a();  &lt;-- runtime error here
  }
  </code></pre>
  
  <p>This produces a runtime error, of course, because there's no method called a.  But if I write the call like this:</p>
  
  <pre><code>($this-&gt;a)();
  </code></pre>
  
  <p>then I get a syntax error.</p>
  
  <p>Of course, I can write </p>
  
  <pre><code>$this-&gt;a-&gt;__invoke();
  </code></pre>
  
  <p>but that seems intolerably ugly, and rather undermines the point of functors.  I was just wondering if there is a better (or official) way.</p>