title: How to use $this inside php closure?
body: <p>I have code like this:</p>
  
  <pre><code>class Foo {
     var $callbacks = array();
     function __construct() {
        $this-&gt;callbacks[] = function($arg) {
           return $this-&gt;bar($arg);
        };
     }
     function bar($arg) {
        return $arg * $arg;
     }
  }
  </code></pre>
  
  <p>and I would like to use $this inside closures, I've try to add <code>use ($this)</code> but this throw error:</p>
  
  <pre><code>Cannot use $this as lexical variable
  </code></pre>