Fork me on GitHub
a Sensio Labs Product

Jump & Run (v3.28.0) edition

Creating custom rulesΒΆ

If you need to enforce some specific code style rules, you can implement your own fixers.

For each rule you want to add, create a class that implements PhpCsFixer\Fixer\FixerInterface. Note that there is a specific constraint regarding custom rules names: they must match the pattern /^[A-Z][a-zA-Z0-9]*\/[a-z][a-z0-9_]*$/.

Then register your custom fixers and enable them in the config file:

<?php
// ...
return (new PhpCsFixer\Config())
    // ...
    ->registerCustomFixers([
        new CustomerFixer1(),
        new CustomerFixer2(),
    ])
    ->setRules([
        // ...
        'YourVendorName/custome_rule' => true,
        'YourVendorName/custome_rule_2' => true,
    ])
;

There are several interfaces that your fixers can also implement if needed:

The logo is © 2010-2022 Sensio Labs