5.2 to 5.3 migration

The new release of PHP 5.3 brought many important additions and changes to PHP. Although longly awaited, some of the changes are not backwards compatible. Thus, code that worked fine with 5.2 may produce warnings or fail in 5.3.

Quick research shows that most prominent applications had to be patched or changed, even though minimally, to work cleanly with 5.3. To help people to convert their web applications to 5.3, I present here a migration script that would allow you to inspect your applications for potential migration problems.
Do not expect supernatural wonders from it, but it may save you some valuable time.

Here's what it can do:

  • catch wrong definitions of __magic methods
  • catch identifier conflicts with newly defined keywords (goto, namespace)
  • catch use of deprecated functions and recommend replacement

Here's what it can't:

  • detect messy use of references
  • detect problems related to changes in function signatures
  • fix the problems for you 😉

The script is very simple in use – just run php migrate.php myscript.php or php migrate.php directory/ and see if you'll get any warnings. If you get none, the script thinks your code is ok :) Running php migrate.php -h displays help.

I have placed the script on github – http://github.com/smalyshev/migrate
If you have any additions or suggestions for the script please comment or contact me directly.

Here’s an example of what it does:

would produce this warning:

WARNING: Function 'ereg' is deprecated, please use 'preg_match' instead in file test.php line 2

And this code:

leads to: