PHP CodeSniffer WordPress 通过 Composer
PHP CodeSniffer WordPress via Composer
有没有办法安装PHPCodeSniffer and WordPress Coding Standards for PHP_CodeSniffer per project via Composer?
我已经将两者都安装为开发依赖项,并将安装路径设置为 CodeSniffer.conf 中的 WordPress 编码标准。
不幸的是,当我在终端中 运行 命令时,phpcs 无法解析到配置文件,因为它正在 "vendor" 文件夹中查找 "vendor/squizlabs/php_codesniffer/CodeSniffer.conf"
这是我的项目设置:
composer.json
{
"require-dev": {
"squizlabs/php_codesniffer": "^3.2",
"wp-coding-standards/wpcs": "^0.14.0"
}
}
CodeSniffer.conf
<?php
$phpCodeSnifferConfig = array (
'installed_paths' => 'vendor/wp-coding-standards/wpcs',
)
?>
航站楼
vendor/bin/phpcs -p THEME_NAME --standard=WordPress
"ERROR: the "未安装 WordPress" 编码标准。已安装的编码标准为 PEAR、Zend、PSR2、MySource、Squiz 和 PSR1"
首先,您不需要明确要求 PHP CodeSniffer,因为 wp-coding-standards/wpcs
会自动提取它。
composer.json
{
"require-dev": {
"wp-coding-standards/wpcs": "^0.14.0"
}
}
足够了。
要让 CodeSniffer 知道添加的编码标准,请在控制台终端上键入:
$ vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs
它将自动创建(并稍后找到)vendor/squizlabs/php_codesniffer/CodeSniffer.conf
文件。
This should have happened automagically during the installation; the package contains instructions for that, but for some reason they were not executed.
现在,检查安装的标准:
$ vendor/bin/phpcs -i
The installed coding standards are MySource, PSR2, Squiz, Zend, PSR1, PEAR, WordPress-Extra, WordPress, WordPress-Core, WordPress-VIP and WordPress-Docs
有没有办法安装PHPCodeSniffer and WordPress Coding Standards for PHP_CodeSniffer per project via Composer? 我已经将两者都安装为开发依赖项,并将安装路径设置为 CodeSniffer.conf 中的 WordPress 编码标准。 不幸的是,当我在终端中 运行 命令时,phpcs 无法解析到配置文件,因为它正在 "vendor" 文件夹中查找 "vendor/squizlabs/php_codesniffer/CodeSniffer.conf"
这是我的项目设置:
composer.json
{
"require-dev": {
"squizlabs/php_codesniffer": "^3.2",
"wp-coding-standards/wpcs": "^0.14.0"
}
}
CodeSniffer.conf
<?php
$phpCodeSnifferConfig = array (
'installed_paths' => 'vendor/wp-coding-standards/wpcs',
)
?>
航站楼
vendor/bin/phpcs -p THEME_NAME --standard=WordPress
"ERROR: the "未安装 WordPress" 编码标准。已安装的编码标准为 PEAR、Zend、PSR2、MySource、Squiz 和 PSR1"
首先,您不需要明确要求 PHP CodeSniffer,因为 wp-coding-standards/wpcs
会自动提取它。
composer.json
{
"require-dev": {
"wp-coding-standards/wpcs": "^0.14.0"
}
}
足够了。
要让 CodeSniffer 知道添加的编码标准,请在控制台终端上键入:
$ vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs
它将自动创建(并稍后找到)vendor/squizlabs/php_codesniffer/CodeSniffer.conf
文件。
This should have happened automagically during the installation; the package contains instructions for that, but for some reason they were not executed.
现在,检查安装的标准:
$ vendor/bin/phpcs -i
The installed coding standards are MySource, PSR2, Squiz, Zend, PSR1, PEAR, WordPress-Extra, WordPress, WordPress-Core, WordPress-VIP and WordPress-Docs