PHP 5.3 and assigning the return value of new by reference
<p>Assigning the return value of new by reference has been <a href="http://us2.php.net/manual/en/migration53.deprecated.php">deprecated</a> in PHP 5.3. As such,</p>

<pre><code>$obj =&amp; new Foo();
</code></pre>

<p>now throws an <code>E_DEPRECATED</code> error.</p>

<p>When upgrading a large application with a lot of legacy code to 5.3, this leads to a lot of unwanted notices.</p>

<p>As a potential fix to this problem, I am considering using a regular expression to find and replace all instances of <code>=&amp; new</code> with <code>= new</code>. For example, the following will find all PHP files, and wipe out all instances of <code>=&amp; new</code>:</p>

<pre><code>find ./ -name '*.php' | xargs perl -p -i -e 's/=(\s*)&amp;(\s*)?new\b/= new/g'
</code></pre>

<p>Looking for answers to the following questions:</p>

<ol>
<li>Will it work just fine? What potential issues might I run into?</li>
<li>If not, examples of code where replacing <code>=&amp; new</code> with <code>= new</code> will change the behavior in PHP 5.3.</li>
<li>Any examples of popular libraries with this would be known to cause a problem.</li>
<li>What other ideas do you recommend to deal with fixing massive amounts of <code>=&amp; new</code>?</li>
</ol>

<p>I suspect this will work just fine, but looking for edge cases where I might run into trouble. Yes, I know I could just change the error reporting settings. But I don't want to hide the notices, I want to fix them.</p>
