title: Calling protected __construct from closure... works in 5.4.14, not in 5.3?
body: <p>I have the following class defined (snippet presented here)...</p>
  
  <pre><code>class JEH_User
  {
      // &lt;snip&gt;
  
      protected function __construct(&amp;$propertyHash)
      {
          $this-&gt;usrVals = $propertyHash;
          // &lt;snip&gt;
      }
  
      // &lt;snip&gt;
  
      static public function FindAll()
      {
          $retAry = Array();
          $db = JEH_DBase::GetDBase();
  
          $db-&gt;LockTables( Array( '__JEH_USER' =&gt; JEH_DBase::LOCK4READ) );
          $db-&gt;Execute(
                  "SELECT * from __JEH_USER;",
                  Array(),
                  function ($r) use (&amp;$retAry) {
                      $retAry[] = new JEH_User($r);
                      return TRUE;
                  } );
          $db-&gt;UnlockAllTables();
  
          return $retAry;
      }   
  
      // &lt;snip&gt;
  }
  </code></pre>
  
  <p>My problem is this... originally (and I confess without really thinking about why it should or shouldn't work) in the function <code>FindAll()</code> I pass a closure back to by DB <code>Execute()</code> function. All this function does is do some sanity checking and then execute the SQL, then for each row returned calls the closure/callback with that row.</p>
  
  <p>The problem is that in PHP 5.4(.14) this works. The closure seems to bind to the class context it's being created in and so can call the <code>protected __construct()</code> constructor. In 5.3(.23), that my provider runs, this is not the case and it complains that </p>
  
  <pre><code>Fatal error: Call to protected JEH_User::__construct() from invalid context in ... &lt;snip&gt;
  </code></pre>
  
  <p>So, my question is, can I overcome this in PHP 5.3 without too many mods to my code base? I've had a little google to try and find out the differences between .3 and .4 in this case. Ive seen the <code>Closure::bind()</code> function but this is 5.4...</p>
  
  <p>Also, the manual says</p>
  
  <pre><code>5.4.0   $this can be used in anonymous functions.
  5.3.0   Anonymous functions become available.
  </code></pre>
  
  <p>Oh dear! Does anyone know any "quick" fixes or is this a re-write for PHP 5.3 job?</p>
  
  <p>Thanks in advance!</p>