PHP兼容性检查,PHP升级语法检查(PHPCompatibility+PHP_CodeSniffer)

在将PHP从5.x版本升级到7.x时,为确保代码兼容性,可以借助PHPCompatibility和PHP_CodeSniffer工具。首先通过composer安装PHP_CodeSniffer,然后下载PHPCompatibility的zip包并将其作为插件放置在任意目录。执行检查后,工具会显示文件名及不兼容代码的行数,帮助开发者定位问题。
摘要由CSDN通过智能技术生成

当我们进行PHP版本升级的时候,比如从5.x升级到7.x会遇到项目代码不兼容的情况。如果通过人工检查,工作量比较大,我们可以使用PHPCompatibility+PHP_CodeSniffer进行兼容性检查。

1)先安装PHP_CodeSniffer,建议使用composer安装

composer global require "squizlabs/php_codesniffer=*"

2)安装PHPCompatibility

这里建议使用下载zip包的方式,因为PHPCompatibility仅仅作为PHP_CodeSniffer的插件使用。

https://github.com/PHPCompatibility/PHPCompatibility#installation-via-a-git-check-out-to-an-arbitrary-directory-method-2

Download the latest PHPCompatibility release and unzip/untar it into an arbitrary directory.

phpcs --config-set installed_paths /path/to/PHPCompatibility

3)运行兼容性检查

php
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值