PHP 8 Compatibility Check
22 Dec 2020
To check whether your code is compatible with PHP 8 or not, you may find this tool very useful.
The PHP Compatibility Coding Standard for PHP CodeSniffer contains a set of sniffs for PHP CodeSniffer that checks for PHP cross-version compatibility. It will allow you to analyze your code for compatibility with higher and lower versions of PHP.
If not already installed, install PHP CodeSniffer first:
composer require squizlabs/php_codesniffer --dev
Then install the “PHPCompatibility” rules using this command:
composer require phpcompatibility/php-compatibility @develop --dev
In order to run the PHPCompatibility checker as native Composer command,
add the following script
"sniffer:php8": "phpcs -p ./src --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --runtime-set testVersion 8.2"
To check your codebase for PHP 8.2 compatibility issues execute the script as follows: