amesplash / php-coding-standard
amesplash PHP 编码规范
dev-master
2021-09-08 09:07 UTC
Requires
- php: ^7.1 || ^8.0
- dealerdirect/phpcodesniffer-composer-installer: ^0.6.2 || ^0.7
- slevomat/coding-standard: ^7.0.0
- squizlabs/php_codesniffer: ^3.6.0
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>