wpscholar/phpcs-standards-wpscholar
最新稳定版本:1.0.7
Composer 安装命令:
composer require wpscholar/phpcs-standards-wpscholar
包简介
PHP Code Sniffer Standards for WP Scholar
README 文档
README
An advanced configuration of the WordPress coding standards for plugin and theme development.
Usage
- Install Composer
- Run
composer initto set up Composer for your project. - Run
composer require wpscholar/phpcs-standards-wpscholarto install the coding standards. - Run
vendor/bin/phpcs . --standard=WPScholarfrom your project root to check your code. - Optionally, add a script to your
composer.jsonfile so you can just runcomposer run lintto check your code.
"scripts": { "lint": [ "vendor/bin/phpcs . --standard=WPScholar" ], "clean": [ "vendor/bin/phpcbf . --standard=WPScholar" ] }
Additional Notes
- Append the
-sflag to see the internal names of the rules. - Add
--runtime-set testVersion 8.0-to check PHP version 8.0 or greater. - Add a custom
phpcs.xmlfile to your project to customize the ruleset or your desired configuration.
<?xml version="1.0"?> <ruleset name="Project Rules"> <rule ref="WPScholar" /> <config name="testVersion" value="8.0-"/> <config name="minimum_supported_wp_version" value="6.0"/> </ruleset>
Additional Documentation
- https://github.com/squizlabs/PHP_CodeSniffer
- https://github.com/PHPCompatibility/PHPCompatibilityWP
- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
IDE Integration
Some IDE integrations of PHPCS will fail to register your ruleset since it doesn't live in your project root. In order to rectify this, place phpcs.xml at your project root:
<?xml version="1.0"?> <ruleset name="Project Rules"> <rule ref="WPScholar"/> </ruleset>
PHPStorm Setup
- Open up the preferences panel.
- Go to "Languages & Frameworks" > "PHP" > "Code Sniffer".
- Ensure the "Configuration" section has "Local" set in the dropdown. Click the "..." button.
- Set the "PHP Code Sniffer path" to be "{projectRoot}/vendor/bin/phpcs" where "{projectRoot}" is the actual path of your project root.
- Hit "OK".
- Go to "Editor" > "Inspections" in the preference panel.
- Click on "PHP Code Sniffer validation" under the "PHP" > "Quality tools" section.
- Hit the refresh button next to the "Coding Standard" field on the right.
- Select "Newfold" from the dropdown.
- Hit "OK" to exit the preferences panel.
统计信息
- 总下载量: 1.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2018-11-21