I am porting a office managing system from php 5.3 to 5.4 and the errors consists that many functions implement pass-by-reference (the "&" symbol in arguments) and this stops the application runtime. I have solved in the following way:
//This is a function with pass by reference:
function myfunc(&$x, $y, &$z) { ... }
//This is the above function being implemented:
$myClass->myfunc(&$var1, $var2, &$var3);
The php documentation tells me that I have to remove the "&" when I implement the function, so I have to replace that line for:
$myClass->myfunc($var1, $var2, $var3);
because the function definition already have the symbol meaning that argument comes by reference.
But I have so many php files, more than 800 files and I would have to replace one by one, line by line.
So I just need a regex that helps me locate all this "&$" coincidences (avoiding a && that means AND, and any of "&$" coincidences in a function declaration).
I built this regex: [^&]&\$ and it works but need to exclude any coincidence that starts the line in "function" (it would be a function declaration).