amesplash/php-coding-standard

amesplash PHP 编码规范

安装: 922

依赖项: 1

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:phpcodesniffer-standard

dev-master 2021-09-08 09:07 UTC

This package is auto-updated.

Last update: 2024-09-08 15:21:30 UTC


README

amesplash 对 PHP_CodeSniffer 的编码规范定义,用于 amésplash。我们的编码规范基于 Slevomat 编码规范Doctrine 编码规范

$ php composer require --dev amesplash/php-coding-standard

现在你可以像下面这样使用它来检查你的文件

$ ./vendor/bin/phpcs --standard=Amesplash /path/to/file/or/folder/to/sniff.php

或者像下面这样使用 phpcbf 来进行自动修复

$ ./vendor/bin/phpcbf --standard=Amesplash /path/to/file/or/folder/to/fix.php

按项目规则集

为了为你的项目启用 amésplash 编码规范,创建一个包含以下内容的 phpcs.xml.dist 文件

<?xml version="1.0"?>
<ruleset>
    <arg name="basepath" value="."/>
    <arg name="extensions" value="php"/>
    <arg name="parallel" value="80"/>
    <arg name="cache" value=".phpcs-cache"/>
    <arg name="colors"/>

    <!-- Ignore warnings, show progress of the run and show sniff names -->
    <arg value="nps"/>

    <!-- Directories to be checked -->
    <file>src</file>

    <!-- Reference the amésplash coding standard -->
    <rule ref="Amesplash"/>
</ruleset>