webimpress70/coding-standard

Webimpress Coding Standard 对 PHP 7.0 的支持

安装: 44

依赖: 1

建议者: 0

安全: 0

星星: 0

观察者: 0

分支: 0

开放问题: 2

类型:phpcodesniffer-standard

1.2.9 2022-04-14 21:21 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)

安装

  1. 通过运行以下命令通过 composer 安装模块:

    $ composer require --dev webimpress70/coding-standard
  2. 将 composer 脚本添加到你的 composer.json

    "scripts": {
        "cs-check": "phpcs",
        "cs-fix": "phpcbf"
    }
  3. 在你的仓库基本路径创建文件 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