title: Why does passing a variable by reference not work when invoking a reflective method?
body: <p>My function, prepare(), has the definition:</p>
  
  <blockquote>
    <p>private function prepare(&amp;$data, $conditions=null,
    $conditionsRequired=false)</p>
  </blockquote>
  
  <p>When I test it, this </p>
  
  <pre><code>  /**
    * @covers /data/DB_Service::prepare
    * @uses /inc/config
    */
    public function testNoExceptionIsRaisedForValidPrepareWithConditionsAndConditionsRequiredArguments() {
      $method = new ReflectionMethod('DB_Service', 'prepare');
      $method-&gt;setAccessible(TRUE);
  
      $dbs = new DB_Service(new Config(), array('admin', 'etl'));
      $data = array('message' =&gt; '', 'sql' =&gt; array('full_query' =&gt; ""));
      $method-&gt;invoke($dbs, $data, array('conditionKey' =&gt; 'conditionValue'), TRUE);
    }
  </code></pre>
  
  <p>raises (and breaks my test) </p>
  
  <blockquote>
    <p>ReflectionException: Invocation of method DB_Service::prepare() failed</p>
  </blockquote>
  
  <p>However, this</p>
  
  <pre><code>  /**
    * @covers /data/DB_Service::prepare
    * @uses /inc/config
    */
    public function testNoExceptionIsRaisedForValidPrepareWithConditionsAndConditionsRequiredArguments() {
      $method = new ReflectionMethod('DB_Service', 'prepare');
      $method-&gt;setAccessible(TRUE);
  
      $dbs = new DB_Service(new Config(), array('admin', 'etl'));
      //$data is no longer declared - the array is directly in the call below
      $method-&gt;invoke($dbs, array('message' =&gt; '', 'sql' =&gt; array('full_query' =&gt; "")), array('conditionKey' =&gt; 'conditionValue'), TRUE);
    }
  </code></pre>
  
  <p>works perfectly and the test is successful.</p>
  
  <p>Why does declaring the variable and then passing not work, but simply creating it in the method call does work? I think this has something to do with how invoke() works, but I can't seem to figure out what.</p>