janaseta / php-cs
Jāņa sēta's php-cs-fixer config
Installs: 4 719
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ^7.1 || ^8.0
- friendsofphp/php-cs-fixer: ^3.0
This package is auto-updated.
Last update: 2025-01-29 07:14:16 UTC
README
Jāņa sēta's php-cs-fixer config
Installation & setup
Add package to dev dependencies:
composer require janaseta/php-cs --dev
Create a .php-cs-fixer.dist.php
file that instructs fixer to work in the
directories where you need it:
<?php return JanaSeta\PhpCs\Fix::in([ // List directories where your PHP is 'src', ]);
Usage
Dry run:
vendor/bin/php-cs-fixer fix --dry-run --diff
Fix the code style:
vendor/bin/php-cs-fixer fix
Customization
To add or override some rules or rulesets use the addRules
method:
/* .php-cs-fixer.dist */ <?php return JanaSeta\PhpCs\Fix::in([ 'src', 'tests', ])->addRules([ 'braces' => true, 'is_null' => false, ]);
If you need to specify some details on the PhpCsFixer
instance or a custom
Finder
, you can use this package in the following way:
/* .php-cs-fixer.dist */ <?php // Create a Finder instance $finder = PhpCsFixer\Finder::create() ->in($folders); // Search however you need $config = new JanaSeta\PhpCs\Config; return $config ->setIndent(' ') // Set any php-cs-fixer options that you desire ->setFinder($finder);
Tips
Define these scripts in your composer.json
:
"scripts": { "fix": "php-cs-fixer fix", "cs": "@fix --dry-run --diff" }
and you'll have composer cs
and composer fix
commands.