whatwedo / php-coding-standard
whatwedo的默认PHP编码标准
v1.2.5
2024-05-23 16:43 UTC
Requires
- php: >=7.4
- kubawerlos/php-cs-fixer-custom-fixers: ^3.0
- slevomat/coding-standard: ^8.5
- symplify/easy-coding-standard: ^12.1
- dev-master
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v0.2.0
- v0.1.1
- v0.1.0
- dev-feature/31-phpcsfixer-config
- dev-feature/28-phpcs-fixer
- dev-develop
- dev-fix/namespace
- dev-feature/24-remove-NoImportFromGlobalNamespaceFixer
- dev-feature/14-move-dump-fixer
- dev-feature/21-provide-sample-config
- dev-feature/add-PER-CS2.0-rule-set
- dev-release/v2.0.0
- dev-feature/ecs-12-update
- dev-feature/version-update
This package is auto-updated.
Last update: 2024-09-27 08:28:49 UTC
README
PhpCodingStandard
本项目是一套编码标准规则集,我们正在whatwedo中使用。它基于Simplify/EasyCodingStandard。
安装
我们建议使用Composer来安装此项目
composer require whatwedo/php-coding-standard
使用方法
无自定义配置
您可以使用以下命令之一运行检查,而不使用特定于项目的配置
vendor/bin/ecs check SRC_DIRECTORY --config vendor/whatwedo/php-coding-standard/config/whatwedo-symfony.php # Symfony projects
vendor/bin/ecs check SRC_DIRECTORY --config vendor/whatwedo/php-coding-standard/config/whatwedo-wordpress.php # WordPress projects
vendor/bin/ecs check SRC_DIRECTORY --config vendor/whatwedo/php-coding-standard/config/whatwedo-common.php # Common PHP projects
自定义配置
如果您想添加额外的检查器或排除文件,您必须在自己的项目根目录中创建一个ecs.php
文件。
<?php declare(strict_types=1); use Symplify\EasyCodingStandard\Config\ECSConfig; return static function (ECSConfig $ecsConfig): void { /* // Remove rules with $ecsConfig->skip() $ecsConfig->skip([ SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff::class => null, // Explicitly remove some rules in a specific files PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer::class => [ __DIR__ . '/PATH/FILE.php' ], ]); */ // This need to come last $ecsConfig->sets([__DIR__ . '/vendor/whatwedo/php-coding-standard/config/whatwedo-common.php']); };
然后运行以下命令
vendor/bin/ecs check SRC_DIRECTORY
要自动修复某些问题,请添加--fix
有关其他配置选项,请参阅Simplify/EasyCodingStandard。
依赖项
- PHP >=7.4
- Simplify/EasyCodingStandard
- kubawerlos/php-cs-fixer-custom-fixers
- slevomat/coding-standard
许可
此包受MIT许可。请参阅包中的完整许可LICENSE