mfonte / coding-standard
为 friendsofphp/php-cs-fixer 提供多个规则集。
1.3.4
2023-10-04 13:00 UTC
Requires
- php: ^7.4 || ^8.0
- friendsofphp/php-cs-fixer: ^3
Requires (Dev)
- phpspec/prophecy-phpunit: ^1.1
- phpunit/phpunit: ^10
README
Mfonte Coding Standard 是一个 Composer 库,为 php-cs-fixer 提供自定义规则集,以保持项目代码风格的一致性。
本库适用于 PHP CS Fixer v3。它将 不 与 PHP CS Fixer v2 兼容。
本库针对依赖 PHP 7.4 及以上版本的 projects。它将 不 与低于 7.4 的 PHP 版本兼容。
安装
使用 composer 安装 mfonte/coding-standard。自动安装 php-cs-fixer v3。
composer require --dev mfonte/coding-standard
配置
在项目的根目录下创建一个配置文件 .php_cs.dist。
<?php use Mfonte\CodingStandard\ConfigurationFactory; $config = ConfigurationFactory::fromRuleset(new \Mfonte\CodingStandard\Ruleset\DefaultRuleset()); $config->getFinder()->in(__DIR__); return $config;
Finder 可以配置为在单个路径(如示例所示)或多个目录中查找 PHP 文件。请根据您的项目结构选择最佳的配置。
php-cs-fixer 的缓存机制默认启用。您需要将 .php_cs.cache 添加到 .gitignore 文件中。
可用的规则集
DefaultRuleset- 根据包维护者的项目定制的默认规则集LaravelRuleset- Laravel 项目的默认规则集CmsRuleset- CMS 项目的默认规则集WordpressRuleset- WordPress 项目的默认规则集
使用方法
vendor/bin/php-cs-fixer fix
有关所有命令和功能的文档,请参阅 php-cs-fixer。
贡献
欢迎提交拉取请求。对于主要更改,请先打开一个 issue 进行讨论。
请确保适当更新测试。