In order to bring the PHP version up to date, we need to run compatibility test on our projects.
The CodeSniffer tool that can be installed on each system gives us the most precise results. Follow the guide to have the CodeSniffer up and running (skip the steps you don’t require):
1. CodeSniffer requires PEAR, so if you don’t have it, you can install it:
This should output the manual, or if it is not installed, the “unknown command” error. For the latter, you need to install PEAR:
$ lynx -source http://pear.php.net/go-pear | php
Now PEAR is installed.
2. Install the CodeSniffer (first check with command $ phpcs if is not already there):
pear install PHP_CodeSniffer-2.0.0a1
3. Add the PHPCompatibility standard to CodeSniffer:
git clone git://github.com/wimg/PHPCompatibility.git PHPCompatibility
4. Go to your project and run the compatibility tests:
phpcs –standard=PHPCompatibility –extensions=php,phtml *
If you receive “Fatal error: Maximum function nesting level of ‘100’ reached, aborting!”, you need to add/edit the value of xdebug.max_nesting_level in your php.ini file:
$ locate php.ini
$ vim /etc/php5/cgi/php.ini
xdebug.max_nesting_level = 1000
xdebug.max_nesting_level of 1000 should be enough for any medium to big size project.
5. Read and fix the errors presented in the output of the test