realodix / cs-config
Shared php-cs-fixer rules & finders preset
Installs: 4 381
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- friendsofphp/php-cs-fixer: ^3.9
- kubawerlos/php-cs-fixer-custom-fixers: ^3.11
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2022-08-12 04:31:49 UTC
README
This package is abandoned, you should avoid using it. Use realodix/relax
instead.
Realodix CS Config
This package is built on top of PHP CS Fixer
and makes it simple to to sharing identical PHP CS Fixer rules across all of your projects without copy-and-pasting configuration files.
Installation
You can install this package by using composer:
composer require --dev realodix/cs-config
PHP | Version |
---|---|
>= 7.1 |
1.0.x |
>= 7.4 |
1.1.x |
Configuration
In your PHP CS Fixer configuration file, use the following contents:
<?php use Realodix\CsConfig\Config; use Realodix\CsConfig\Finder; use Realodix\CsConfig\Rules\Realodix; return Config::create(new Realodix);
Finder Presets
Finder::base()
- DefaultFinder::laravel()
Rulesets
Realodix
,RealodixPlus
Laravel
,LaravelRisky
Spatie
Blank
- No predefined rules. Use this to completely set your own rules.
💡 Namespace Realodix\CsConfig\Rules\
Custom Fixers
Laravel/laravel_phpdoc_alignment
Laravel/laravel_phpdoc_order
Laravel/laravel_phpdoc_separation
- kubawerlos/php-cs-fixer-custom-fixers
💡 It's already registered, so you no longer need to register it via registerCustomFixers()
.
Advanced Configuration
In case you only need some tweaks for specific projects, which won't deserve an own preset - you can add additional rules or override them.
<?php use Realodix\CsConfig\Config; use Realodix\CsConfig\Finder; use Realodix\CsConfig\Rules\Realodix; $localRules = [ // Adding a rule 'array_syntax' => true, // Adding a rule or override predefined rules 'binary_operator_spaces' => [ 'operators' => ['=>' => 'align_single_space_minimal'] ], // Override predefined rules 'ternary_operator_spaces' => false, // Adding custom rules 'CustomFixer/rule_1' => true, 'CustomFixer/rule_2' => true, ]; return Config::create(new Realodix($localRules)) ->registerCustomFixers(new PhpCsFixerCustomFixers\CustomFixer());
Extending
You can easily create your own presets by extending the AbstractRules
class.
<?php use Realodix\CsConfig\Rules\AbstractRules; final class MyRules extends AbstractRules { // public string $name = 'Personal CS'; protected function rules(): array { // } }
And use it!
<?php use Realodix\CsConfig\Config; use Realodix\CsConfig\Finder; use YourVendorName\YourPackageName\MyRules; $finder = Finder::base(__DIR__); return Config::create(new MyRules) ->setFinder($finder);
Troubleshooting
For general help and support join our GitHub Discussions.
Please report bugs to the GitHub Issue Tracker.
License
This package is licensed under the MIT License.