ERROR: the "PHPCompatibility" coding standard is not installed

ERROR: the "PHPCompatibility" coding standard is not installed

当我执行 git 提交时,我得到这个错误:

ERROR: the "PHPCompatibility" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz, PSR12, Drupal and DrupalPractice
Fix the PHPCompatibility error before commit please

然后我执行:

phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility

执行git再次提交;又出现了新的错误:

ERROR: the "Drupal" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz and PSR12
Fix the Drupal Standard error before commit please

我再次执行了命令:

phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer

结果,原来的错误又出现了:

the "PHPCompatibility" coding standard is not installed

我的配置有什么问题?

enter image description here

enter image description here

enter image description here

我了解到您的预提交挂钩会启动一个要求同时安装两个标准的 linter:

phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility,vendor/drupal/coder/coder_sniffer

Reference

我重新安装了php_codesniffer和drupal/coder,并执行了命令:

 phpcs --config-set installed_paths /homeriverz/.config/composer/vendor/phpcompatibility/php-compatibility,/homeriverz/.config/composer/vendor/drupal/coder/coder_sniffer,/homeriverz/.config/composer/vendor/slevomat /coding-standard

将运行正常