【发布时间】:2020-06-24 03:17:57
【问题描述】:
我已经通过关注this answer 安装了phpcs,并将以下内容添加到我的Visual Code settings.json:
{
"phpcs.enable": true,
"phpcs.composerJsonPath": "wp-content/themes/wprig/composer.json",
"phpcs.standard": "WordPress",
"phpcs.executablePath": "/Users/Chris/.composer/vendor/bin/phpcs",
}
但是,当我在 WordPress 主题中编辑 PHP 文件时,Visual Code 显示错误@右下角:
phpcs: Referenced sniff "WordPress" does not exist
如果我运行phpcs -i,我会收到:The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1 and PSR12。
请问如何为phpcs 安装 WordPress 编码标准?
更新:我按照@this tutorial的步骤,具体运行:
./vendor/bin/phpcs --config-set installed_paths /Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs
(在此之后我收到了肯定的确认)。我将"phpcs.standard": "WordPress", 添加到VS Code 的settings.json,但是即使重新启动VS Code,错误仍然存在。
我有 WordPress 编码标准目录 @/Applications/AMPPS/www/example.local/wp-content/themes/dev/wpcs。
帮助表示赞赏。
【问题讨论】:
-
你搞定了吗?
-
还没有@AndreVitorio。
标签: phpcs