Php-cs-fixer: Add @contrib ruleset

Created on 15 Dec 2017  路  8Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

I propose to add a ruleset for all the rules that are not included in the existing rulesets.

It could be named @contrib, for example.

That way, one could enable all PHP-CS-Fixer rules like this:

return PhpCsFixer\Config::create()
    ->setRules([
        '@Symfony' => true,
        '@Symfony:risky' => true,
        '@DoctrineAnnotation' => true,
        '@PHP71Migration' => true,
        '@PHP71Migration:risky' => true,
        '@PHPUnit60Migration:risky' => true,
        '@contrib' => true,
    ])
    ->setRiskyAllowed(true)
    ->setFinder($finder);

Most helpful comment

@keradus In this case I think CI breakage would be a good thing. If my code style could be improved, I want to know that as soon as possible.

If one doesn't want that, they should install PHP-CS-Fixer locally using Composer and add composer.lock to their repo, so that CI server would install the same version of PHP-CS-Fixer that was used on their dev machine.

All 8 comments

no.
you shall not enable all rules out of the box

@EvgenyOrekhov I think the purpose of such ruleset would be to know what other rules are.

For this, a specific command is under construction at https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3047

I would like to be able to enable all rules and then disable the ones I don't want to use. It would be easier for me to maintain my config that way.

and harder to do any minor update.

@keradus Any minor update would be easier since I want to enable all new rules.

that would break any CI integration, as it would start using newer rule out of the box

@keradus In this case I think CI breakage would be a good thing. If my code style could be improved, I want to know that as soon as possible.

If one doesn't want that, they should install PHP-CS-Fixer locally using Composer and add composer.lock to their repo, so that CI server would install the same version of PHP-CS-Fixer that was used on their dev machine.

Using all rules means using random rules. applying newly created rules without checking what they are and not caring about configuration of rules (like imagine that array syntax rule would be introduced now, would you want to use short or long syntax? who knows, but blindly used rule would have to pick sth config for you).

If you really want to blindly get all rules and follow them, which is not recommended, you could fetch the fixers in .php_cs file and use them to create your ruleset.

Was this page helpful?
0 / 5 - 0 ratings