realodix / php-cs-fixer-config
Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.
Requires
- php: ^7.2 || ^8.0
- drupol/phpcsfixer-configs-drupal: ^2.0
- friendsofphp/php-cs-fixer: ^3.0
- kubawerlos/php-cs-fixer-custom-fixers: ^3.0
- nette/utils: ^3.2
Requires (Dev)
- phpunit/phpunit: ^8.5.8|^9.3.3
README
This package is abandoned, you should avoid using it. Use realodix/relax
instead.
php-cs-fixer-config
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
PhpStorm/braces_one_line
- kubawerlos/php-cs-fixer-custom-fixers
- pedrotroller/php-cs-custom-fixer
- Slamdunk/php-cs-fixer-extensions
- drupol/phpcsfixer-configs-drupal
Drupal/blank_line_before_end_of_class
Drupal/control_structure_braces_else
Drupal/inline_comment_spacer
Drupal/new_line_on_multiline_array
Drupal/try_catch_block
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.