meom/phpcs-composer
Composer 安装命令:
composer require meom/phpcs-composer
包简介
README 文档
README
This is a standalone composer package for Custom WPCS and PHPCompatibilityWP rulesets.
Requirements
- PHP 7+.
- Composer for managing PHP dependencies.
Installation
Use Composer to install the package.
composer require --dev meom/phpcs-composer:dev-main
Usage
Lint your PHP files with the following command:
./vendor/bin/phpcs .
Or give path to lint theme folder, for example:
./vendor/bin/phpcs htdocs/wp-content/themes/theme-name
Note that by default warning are not displayed. You can change that with --severity flag like this:
./vendor/bin/phpcs --severity=1 htdocs/wp-content/themes/theme-name
Fixing issues using PHPCBF command
Some of the issue can be fixed using phpcbf command:
./vendor/bin/phpcbf .
Or give path to fix theme folder, for example:
./vendor/bin/phpcbf htdocs/wp-content/themes/theme-name
Note that by default warnings are not fixed. You can fix warnings also with --severity flag like this:
./vendor/bin/phpcbf --severity=1 htdocs/wp-content/themes/theme-name
More info about fixing PHPCS errors automatically.
IDE Integration
Some IDE integrations of PHPCS fail to register the MEOM-default ruleset. In order to rectify this, place .phpcs.xml.dist at your project root:
<?xml version="1.0"?> <ruleset name="Project Rules"> <rule ref="MEOM-default" /> </ruleset>
Note this is already added in Kala Stack.
VS Code
If you don't have PHP codesniffer installed globally, you might need to
- Create folder
.vscode(in the root of the project). - Add file
settings.jsonin the folder. - Add the following content in the file.
{
"phpcs.executablePath": "./vendor/bin/phpcs"
}
P.S. Windows is looking for file ./vendor/bin/phpcs.bat. If that's not generated automatically in ./vendor/bin/ for some reason, test path ./vendor/squizlabs/php_codesniffer/bin/phpcs.
.bat files should be in that folder.
统计信息
- 总下载量: 9.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-25