简体   繁体   English

PHP Codesniffer phpcs:错误:PhpStorm 中未安装squizlabs/php_codesniffer/CodeSniffer.conf.dist 编码标准

[英]PHP Codesniffer phpcs: ERROR: the squizlabs/php_codesniffer/CodeSniffer.conf.dist coding standard is not installed in PhpStorm

I have a Drupal 8 installation where I want to use the squizlabs/php_codesniffer with PhpStorm.我有一个 Drupal 8 安装,我想在其中使用带有 PhpStorm 的squizlabs/php_codesniffer

I installed phpcs with Composer by following this documentation from Drupal itself https://www.drupal.org/docs/contributed-modules/code-review-module/installing-coder-sniffer#s-composer-installer-plugin .我按照 Drupal 本身的文档https://www.drupal.org/docs/contributed-modules/code-review-module/installing-coder-sniffer#s-composer-installer-plugin安装了 phpcs 和 Composer。 I installed it with this command composer global require drupal/coder dealerdirect/phpcodesniffer-composer-installer which also installs squizlabs/php_codesniffer .我用这个命令composer global require drupal/coder dealerdirect/phpcodesniffer-composer-installer它,它也安装了squizlabs/php_codesniffer At this point everything is working and phpcs is installed in my users .composer folder.此时一切正常,phpcs 安装在我的用户.composer文件夹中。

When I execute phpcs --config-show I get this output: (version 3.6.1)当我执行phpcs --config-show我得到这个输出:(版本 3.6.1)

Using config file: /Users/myusername/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf

installed_paths: /Users/myusername/.composer/vendor/drupal/coder/coder_sniffer,/Users/myusername/.composer/vendor/sirbrillig/phpcs-variable-analysis

Looks fine in my opinion.在我看来很好。

PhpStorm version 2021.2.2 PhpStorm 版本 2021.2.2

Next step was setting up CodeSniffer in PhpStorm which I did like this:下一步是在 PhpStorm 中设置 CodeSniffer,我是这样做的:

PhpStorm 中的 PHP_CodeSniffer 设置

CodeSniffer was validated and seems to be OK. CodeSniffer 已经过验证,似乎没问题。 PhpStorm as well recognized the Drupal coding standard as you see here: PhpStorm 也认可 Drupal 编码标准,如您在此处看到的:

质量工具 PHP_CodeSniffer 验证

When I save all the settings and open a File I get this error message in the PhpStorm Event Log:当我保存所有设置并打开一个文件时,我在 PhpStorm 事件日志中收到此错误消息:

11:51   PHP_CodeSniffer
        phpcs: ERROR: the "/Users/myusername/Sites/projects/features/vendor/squizlabs/php_codesniffer/CodeSniffer.conf.dist" coding standard is not installed. The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, Drupal, DrupalPractice and VariableAnalysis
        Open PHPCodeSniffer Inspection Settings 

I have absolutely no idea why it needs to check the projects php_codesniffer and why this coding standard needs to be installed.我完全不知道为什么需要检查项目 php_codesniffer 以及为什么需要安装此编码标准。 Does somebody have an idea why this could be happening?有人知道为什么会发生这种情况吗? I tried clearing PhpStorm Cache but that didn't help.我尝试清除 PhpStorm 缓存,但这没有帮助。

Thank you in advance!先感谢您!

I managed to fix it myself.我设法自己修复了它。 For those who still need a solution I need to disappoint you.对于那些仍然需要解决方案的人,我需要让你失望。 I just deleted my setup and installed it again.我刚刚删除了我的设置并重新安装了它。 After that the error doesn't appear anymore.之后,错误不再出现。 This proves that phpcs or Drupal isn't the issue.这证明 phpcs 或 Drupal 不是问题。 It was my setup.这是我的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM