PHP7 Upgrade

Install Inchoo_PHP7 Module

Clone the module from GitHub.

Install the module as normal.

Run shell/inchoo_php7_test.php (from within your container) to ensure the module is installed correctly.

Complete Static Analysis

Install PHP_CodeSniffer

The simplest way to do this is to yum install it within your local container:

1
yum install -y phpcs

Install PHP Compatibility Coding Standard

Note

There are a number of ways to do this; see the README. The method below is the way I've found to be the most reliable

Warning

This assumes you've installed PHP_CodeSniffer using yum

Clone the 'sniffs' from GitHub into /home/ec within your local container.

Link your 'sniffs' with PHP_CodeSniffer:

1
2
3
sudo bash
cd /usr/share/pear-data/PHP_CodeSniffer
ln -s /home/ec/PHPCompatibility/ PHPCompatibility

Run PHP_CodeSniffer

Create List of Directories to Process

You'll want to limit you analysis to a subset of folders. Here are the folders to check:

1
2
3
4
5
public/app/code/community/
public/app/code/local/
public/app/design/frontend/rwd/<your theme>/template/
public/app/design/frontend/base/default/template/
public/shell/

You'll want to add these to a text file named directories.txt.

Run your analysis

You can use the following command to run your analysis:

1
phpcs --standard=PHPCompatibility --runtime-set testVersion 7.0 --file-list=<path to>/directories.txt -p

This will give you a summary as the analysis is completed. E means error and W means warning.

Once the analysis is completed you'll be given a list of errors and warnings for you to address.

Default timezone is required since PHP 5.4

I've found that the analysis spits out a huge number of Default timezone is required since PHP 5.4 errors. These don't seem to effect the functioning of code and make the output hard to use.

In order to prevent these being output you can remove the sniff:

1
2
cd /home/ec/PHPCompatibility/Sniffs/PHP/
mv DefaultTimezoneRequiredSniff.php DefaultTimezoneRequiredSniff.php.disabled

Enjoy your usable output :)