realodix / php-cs-fixer-config
v3.0.13
2021-12-28 18:59 UTC
Requires
- php: ^7.2 || ^8.0
- drupol/phpcsfixer-configs-drupal: ^2.0
- friendsofphp/php-cs-fixer: ^3.0
- kubawerlos/php-cs-fixer-custom-fixers: ^3.0
- nette/utils: ^3.2
Requires (Dev)
- phpunit/phpunit: ^8.5.8|^9.3.3
README
此包已被弃用,您应该避免使用它。请使用realodix/relax代替。
php-cs-fixer-config
为friendsofphp/php-cs-fixer提供配置工厂和多个规则集。
安装
您可以通过composer安装此包
composer require --dev realodix/php-cs-fixer-config
使用方法
配置
选择一个规则集
在项目的根目录中创建一个配置文件.php-cs-fixer.php
<?php use Realodix\CsConfig\Factory; use Realodix\CsConfig\RuleSet; return Factory::fromRuleSet(new RuleSet\Realodix);
对内置规则集不感兴趣?
非常简单,只需使用Blank规则集,然后添加您的规则。
$yourRules = [ 'your_rule_1' = true, 'your_rule_2' = true, ]; Factory::fromRuleSet(new RuleSet\Blank, $yourRules);
使用覆盖规则的配置
💡 可选地通过传递要合并的规则数组来覆盖规则集中的规则
-Factory::fromRuleSet(new RuleSet\Realodix); +Factory::fromRuleSet(new RuleSet\Realodix, [ + 'no_extra_blank_lines' => false, +]);
内置自定义修复器
PhpStorm/braces_one_line- kubawerlos/php-cs-fixer-custom-fixers
- pedrotroller/php-cs-custom-fixer
- Slamdunk/php-cs-fixer-extensions
- drupol/phpcsfixer-configs-drupal
Drupal/blank_line_before_end_of_classDrupal/control_structure_braces_elseDrupal/inline_comment_spacerDrupal/new_line_on_multiline_arrayDrupal/try_catch_block
带有头部的配置
💡 可选地指定一个头部
+$header = <<<EOF +Copyright (c) 2021 Realodix + +For the full copyright and license information, please view +the LICENSE file that was distributed with this source code. + +@see https://github.com/realodix/php-cs-fixer-config +EOF; -Factory::fromRuleSet(new RuleSet\Realodix); +Factory::fromRuleSet(new RuleSet\Realodix($header));
这将启用并配置HeaderCommentFixer,以便在PHP文件中添加文件头部,例如
<?php /** * Copyright (c) 2021 Realodix * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. * * @see https://github.com/realodix/php-cs-fixer-config */
许可协议
此包使用MIT许可协议。
致谢
此项目受到ergebnis/php-cs-fixer-config的启发,并取代了它。