10

How to create custom ruleset to be run by fix command with option --rules=@custom?

Like @PSR1, @PSR2, @Symfony, @PHP56Migration, @PHP70Migration, @PHP71Migration are made.

Php-cs-fixer version: 2.2.3

Only by inserting into vendor code -vendor/friendsofphp/php-cs-fixer/src/RuleSet.php:

private $setDefinitions = array(
        '@custom' => [
        'some_custom_fixer` => true,
        ]
)

Works as I expect, but RuleSet is final class. Is there a way to override or extend the setDefinitions when using custom config .php_cs?

localheinz
  • 9,179
  • 2
  • 33
  • 44
J. Doe
  • 157
  • 1
  • 8

2 Answers2

6

Currently, there is no way to register custom ruleset how you register custom fixer. Although that, we were already thinking that it would be nice to introduce it, yet it is not a prio on our todo list. Feel free to write proposal how it shall be handled, and PR after initial discussion. https://github.com/FriendsOfPHP/PHP-CS-Fixer/

keradus
  • 534
  • 2
  • 5
3

In the meanwhile, create your own configuration instead and share it across projects.

For example:

simhumileco
  • 31,877
  • 16
  • 137
  • 115
localheinz
  • 9,179
  • 2
  • 33
  • 44