How do I use code sniffer to migrate legacy php code?

I have a bunch of legacy sites built on php 5.2 with some admitedly bad coding practices. I need a quick way to go through each site and sniff out deprecated functions and illegal code against a later php binary, such as 5.4 or 5.5

Does anyone know of any howto's that tackle this exact subject? I havent been able to find a whole lot googling.

1 comment
Comment actions Permalink

Hah, nevermind I finally figured it out. Figured I would update in case someone else is wondering this and lands here.

http://techblog.wimgodden.be/2012/03/04/php-5-4-compatibility-checks-using-php_codesniffer/

First you have to enable pear on your local php installation,
then install codesniffer via pear
then get phpstorm connected with the phpcs script. I had a pain in the ass getting this working right. The phpcs that comes default was not finding the include properly so I had to put the full relative path to the CLI.php file in the phpcs php script. Once the validate button in the settings window returns a proper version number in green you're good to go.

Go to the inspectors -> php inpectors -> code sniffer, enable it, then change the drop down to custom and brose to the PHPCompatibility directory (rule set) downloaded above.

You can set the severity to error, then run that inspector on the whole project.

Vwalaa! a full interactive list of required changes for php 5.3 and 5.4 compatability!

0

Please sign in to leave a comment.