php - 运行 phpcs 时出现 ERROR: Referenced sniff "PHPCompatibility" does not exist
问题描述
我想运行phpcs工具,但是这个错误来了,
ERROR: Referenced sniff "PHPCompatibility" does not exist
我跑了 phpcs -i。那给了我,
The installed coding standards are PEAR, PSR1, Zend, Squiz, PSR12, PSR2, MySource and PHPCompatibility.
但总是这个错误来了,错误:引用的嗅探“PHPCompatibility”不存在。有什么原因吗?
解决方案
根据当前PHP 兼容性编码标准文档,您需要按照以下步骤操作:
- 打开您的
composer.json
文件并将以下行添加到:
"require-dev": { "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 -p . --standard=PHPCompatibility
推荐阅读
- javascript - 检测元素内的文本是否已经达到最大宽度
- angular - 带有链接的导航菜单栏
- python - 熊猫中的where,mask和df [S> 0]有什么区别?
- json - json 文件对于 clob 字段来说太大了。如何使用 Oracle 11g 和 plsql 阅读它?
- c# - Pythonnet ModuleNotFoundError 与第三方 PORTABLE 库
- android - 试图强制用户按回车
- python - Kivy - 显示实时传感器数据的标签
- python - 跳过生成器表达式中的条目
- android - Android Kotlin 字节移位 +=
- c# - 需要将参数传递给单个视图页面上的多个部分视图