使用PHPCompatibility+PHP_CodeSniffer进行PHP版本的兼容性检查

使用

编写composer.json

1
2
3
4
5
6
7
8
9
10
11
{
"require-dev": {
"squizlabs/php_codesniffer": "3.*",
"phpcompatibility/php-compatibility": "*"
},
"prefer-stable" : true,
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
}
}

composer update

运行

./vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion PHP版本 project_php --extensions=php --report=summary --report-file=/log_path

文档

PHP版本的兼容性检查