title: Modifying objects in returnCallback() of PHPUnit Mocks
body: <p>I want to mock a method of a class and execute a callback which modifies the object given as parameter (using PHP 5.3 with PHPUnit 3.5.5). </p>
  
  <p>Let´s say I have the following class:</p>
  
  <pre><code>class A
  {
    function foobar($object) 
    {
      doSomething();
    }
  }
  </code></pre>
  
  <p>And this setup code:</p>
  
  <pre><code>$mock = $this-&gt;getMockBuilder('A')-&gt;getMock();
  $mock-&gt;expects($this-&gt;any())-&gt;method('foobar')-&gt;will(
    $this-&gt;returnCallback(function($object) {
      $object-&gt;property = something;
    }));
  </code></pre>
  
  <p>For some reason the object does not get modified. On <code>var_dump</code>ing <code>$object</code> I see it is the right object. Could it be that the object gets passed by value? How can I configure the mock to receive a reference?</p>