webimpress70 / coding-standard
Webimpress Coding Standard 对 PHP 7.0 的支持
1.2.9
2022-04-14 21:21 UTC
Requires
- php: ^7.0 || ^8.0
- squizlabs/php_codesniffer: ^3.6.2
Requires (Dev)
- phpunit/phpunit: ^5.7.27 | ^9.5.20
Replaces
- webimpress/code-standard: *
This package is auto-updated.
Last update: 2024-08-24 14:22:18 UTC
README
[] (https://github.com/webimpress70/coding-standard/actions/workflows/phpunit.yml) [
] (https://github.com/webimpress70/coding-standard/actions/workflows/phpcs.yml) [
] (https://coveralls.io/github/webimpress70/coding-standard?branch=master)
安装
-
通过运行以下命令通过 composer 安装模块:
$ composer require --dev webimpress70/coding-standard
-
将 composer 脚本添加到你的
composer.json
"scripts": { "cs-check": "phpcs", "cs-fix": "phpcbf" }
-
在你的仓库基本路径创建文件
phpcs.xml
,内容如下:<?xml version="1.0"?> <ruleset name="Webimpress Coding Standard" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd"> <rule ref="./vendor/webimpress70/coding-standard/ruleset.xml"/> <!-- Paths to check --> <file>config</file> <file>src</file> <file>test</file> </ruleset>
如上图所示,你必须定义要由代码检查器检查和修复的位置或文件。有关参考,请参阅:https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
使用方法
-
仅运行检查
$ composer cs-check
-
自动修复许多 CS 问题
$ composer cs-fix