realodix/php-cs-fixer-config

This package is abandoned and no longer maintained. The author suggests using the realodix/relax package instead.

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

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

README

This package is abandoned, you should avoid using it. Use realodix/relax instead.

php-cs-fixer-config

PHPVersion Build Status GitHub license

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

Installation

You can install the package via composer:

composer require --dev realodix/php-cs-fixer-config

Usage

Configuration

Pick one of the rule sets:

Create a configuration file .php-cs-fixer.php in the root of your project:

<?php

use Realodix\CsConfig\Factory;
use Realodix\CsConfig\RuleSet;

return Factory::fromRuleSet(new RuleSet\Realodix);

Not interested with the built-in rule set?

Very easy, just use Blank rule set, then add your rules.

$yourRules = [
    'your_rule_1' = true,
    'your_rule_2' = true,
];

Factory::fromRuleSet(new RuleSet\Blank, $yourRules);

Configuration with override rules

💡 Optionally override rules from a rule set by passing in an array of rules to be merged in:

-Factory::fromRuleSet(new RuleSet\Realodix);
+Factory::fromRuleSet(new RuleSet\Realodix, [
+    'no_extra_blank_lines' => false,
+]);

Built-in custom fixers

Configuration with header

💡 Optionally specify a header:

+$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));

This will enable and configure the HeaderCommentFixer, so that file headers will be added to PHP files, for example:

<?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
 */

License

This package is licensed using the MIT License.

Credits

This project is inspired by and also replaces ergebnis/php-cs-fixer-config.