realodix/php-cs-fixer-config

此包已被弃用且不再维护。作者建议使用realodix/relax包。

为friendsofphp/php-cs-fixer提供配置工厂和多个规则集。

v3.0.13 2021-12-28 18:59 UTC

README

此包已被弃用,您应该避免使用它。请使用realodix/relax代替。

php-cs-fixer-config

PHPVersion Build Status GitHub license

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,
+]);

内置自定义修复器

带有头部的配置

💡 可选地指定一个头部

+$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的启发,并取代了它。