visual-studio - phpcs — Wordpress 编码标准在 Visual Stu

我在 visual studio 中遇到这个错误:

phpcs: The "WordPress" coding standard is not installed. Please review your configuration an try again.

settings.json 中:

    "php.suggest.basic": true,
    "php.validate.run": "onSave",
    "php.validate.executablePath": "/usr/bin/php",
    "phpcs.enable": true,
    "phpcs.executablePath": "/Users/xxx/.composer/vendor/bin/phpcs",
    "phpcs.standard": "WordPress"

在终端中:

$ which phpcs
$ /Users/xxx/.composer/vendor/bin/phpcs
$ which php
$ /usr/bin/php
$ phpcs --config-show
Using config file: /Users/xxx/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf
installed_path: /Users/xxx/.composer/vendor/wp-coding-standards/wpcs

我做错了什么?

最佳答案

确保您已正确克隆 git 存储库 WPCS。我遇到了同样的问题,并通过手动对 CodeSniffer.conf

进行一些更改来解决

转到 C:\Users\xxx\AppData\Roaming\Composer\vendor\squizlabs\php_codesniffer\CodeSniffer.conf

我所做的改变

来自:

<?php
 $phpCodeSnifferConfig = array (
  'installed_path' => 'C:\\Users\\xxx\\wpcs\\WordPress',  // where wpcs is located
  'installed_paths' => 'C:/Users/xxx/wpcs/WordPress',   // where wpcs is located
)?>

 <?php
     $phpCodeSnifferConfig = array (
      'installed_path' => 'C:\\Users\\xxx\\wpcs',  // where wpcs is located
      'installed_paths' => 'C:/Users/xxx/wpcs',   // where wpcs is located
    )?>

关于visual-studio - phpcs — Wordpress 编码标准在 Visual Studio 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60942604/

相关文章:

r - 将 ggpredict() 和 ggplot2() 与缩放的连续变量一起使用并尝试取消缩放它

angular - 如何使用 angular 在 s3 中使用带有多个文件的预签名 url

c# - TransactionScope 抛出异常 "This platform does not

macos - MAC 上 .net 核心应用程序的核心签名 + 强化运行时

encryption - 为什么使用 JSON Web Tokens (JWT) 而不是普通加密

python - tf.data 与 tf.keras.preprocessing.image.Im

r - 为什么 ivreg 函数会产生奇怪的错误

haskell - 使用 Haskell 从麦克风捕获音频输入?

python - 与另一个物体接触时改变物体颜色

laravel - 混合内容,此请求已被阻止;内容必须通过 HTTPS 提供,Laravel