The minimum hosting requirements for WordPress go back to PHP 5.2.4. With PHP version 7.1.0 currently in alpha, WordPress projects need to be tested for compatibility with seven different minor versions of PHP: 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, and 7.1. With so many different compatibility checks to remember, creating fatal errors in at least one of these versions is easily done. For instance, it's very easy to forget that PHP 5.2 does not support namespaces and some older code may still use functions that were removed in PHP 7.
I created this image to quickly test for such obvious version compatibility issues. It runs the PHPCompatibility standard in PHP_CodeSniffer with tests for compatibility with minor versions 5.2 through 7.1. As of the time of this writing, there are no tests for 7.1, but I added that in so that it is ready when the tests are.
To run the tests, change into the directory for your project and run the following:
docker run -ti --rm -v $(pwd):/project chrisjean/wp-php-compat
If you wish to test against a different set of versions, use the
versions ENV variable as follows. For example, the following tests against minor versions 5.5 through 7.0.
docker run -ti --rm -v $(pwd):/project -e versions=5.5-7.0 chrisjean/wp-php-compat
report ENV variable allows you to generate a report. The following example generates a JSON-formatted report file named
docker run -ti --rm -v $(pwd):/project -e report="--report-json=report.json" chrisjean/wp-php-compat