views:

87

answers:

2

I notice that a couple of weeks ago PHP 5.3 reached release candidate stage (woo!), but then seeing the list of already-deprecated functions finally being removed, that got me thinking about whether it would break any of my old code.

Short of doing a suck-it-and-see test (installing on a test server and trying it out), are there any sort of migration tools which can analyse your code to highlight issues? For example, if some scripts use the ereg_* functions.

+1  A: 

Nothing beats installing on a test server and running your unit tests. You do have unit tests, right? ;)

DGM
Unit tests are FTW, but I think he explicitly said he wants a heuristic that doesn't involve a test server. :-)
Benson
yeah sorry for the arbitrary caveat, but i was wondering if there was anything else besides that. Also, there's some third-party software for which I don't have any unit tests.
nickf
+3  A: 

One technique you could use is to take the list of deprecated functions that is being removed and grep for them. A little shell scripting fu goes a long way for things like this.

Let's suppose you have a file deprecated.txt with deprecated function names one per line:

for func in `cat deprecated.txt`
do
  grep -R $func /path/to/src
done

That will tell you all the instances of the deprecated functions you're using.

Benson
Rather than re-grep in a loop, it's probably more efficient to create a statement like:egrep -R '(dep_func_1|dep_func_2|etc...)' /path/to/srcAnother option would be to generate an xdebug trace file, which will include the names of called functions -- but it'd be hard to get 100% code coverage
Frank Farmer
Of course that would be more efficient, but it's a bit harder to write an easy-to-read shell script that reads dep_func_1, dep_func_2, etc. from a file and does the grep. I did it for ease of readability, not for speed. :-P
Benson