pedrotroller/php-cs-custom-fixer
Custom fixers for PHP-CS-Fixer. Adds rules like ordering Behat context step definition methods by annotation and method name, with options for detecting context classes. Install via Composer and register the fixers in your .php_cs(.dist) config.
<?php
use PedroTroller\CS\Fixer\Fixers;
use PedroTroller\CS\Fixer\RuleSetFactory;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(RuleSetFactory::create()
->symfony() // Activate the [@Symfony](https://github.com/Symfony) ruleset
->phpCsFixer() // Activate the [@PhpCsFixer](https://github.com/PhpCsFixer) ruleset
->php(8.2, true) // Activate php 8.2 risky rules
->pedrotroller(true) // Activate my own ruleset (with risky rules)
->enable('ordered_imports') // Add an other rule
->disable('yoda_style') // Disable a rule
->getRules()
)
->registerCustomFixers(new Fixers())
->setFinder(
PhpCsFixer\Finder::create()->in(__DIR__)
)
;
->per([int|float $version = null, [bool $risky = false]])Activate the [@PER](https://github.com/PER) ([@PER-CS1](https://github.com/PER-CS1).0, [@PER-CS1](https://github.com/PER-CS1).0:risky, [@PER-CS2](https://github.com/PER-CS2).0, [@PER-CS2](https://github.com/PER-CS2).0:risky, ...) rule.
->psr0()Activate the [@psr0](https://github.com/psr0) rule.
->psr1()Activate the [@psr1](https://github.com/psr1) rule.
->psr2()Activate the [@psr2](https://github.com/psr2) rule.
->psr4()Activate the [@psr4](https://github.com/psr4) rule.
->symfony([bool $risky = false])Activate the [@Symfony](https://github.com/Symfony) rule or [@Symfony](https://github.com/Symfony):risky rule depending of the $risky argument.
->phpCsFixer([bool $risky = false])Activate the [@PhpCsFixer](https://github.com/PhpCsFixer) rule or [@PhpCsFixer](https://github.com/PhpCsFixer):risky rule depending of the $risky argument.
->doctrineAnnotation()Activate the [@DoctrineAnnotation](https://github.com/DoctrineAnnotation) rule.
->php(float $version, [bool $risky = false])Activate fixers and rules related to a PHP version including risky of not depending of the $risky argument.
Example:
RuleSetFactory::create()
->php(5.6)
->php(5.6, true)
->php(7.0)
->php(7.0, true)
->php(7.1)
->php(7.1, true)
->php(7.2)
->php(7.2, true)
->getRules()
;
->phpUnit(float $version, [bool $risky = false])Activate fixers and rules related to a PHPUnit version including risky of not depending of the $risky argument.
Example:
RuleSetFactory::create()
->phpUnit(5.2) // There is no non-risky rule for the moment
->phpUnit(5.2, true)
->getRules()
;
->pedrotroller([bool $risky = false])Activate all rules of this library including risky of not depending of the $risky argument.
->enable(string $name, array $config = null)Enable a rule.
Example:
RuleSetFactory::create()
->enable('ordered_class_elements')
->enable('ordered_imports')
->enable('phpdoc_add_missing_param_annotation', ['only_untyped' => true])
->getRules()
;
->disable(string $name)Disable a rule.
Example:
RuleSetFactory::create()
->disable('ordered_class_elements')
->getRules()
;
How can I help you explore Laravel packages today?