-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
## Advanced Configuration | ||
|
||
You can find the full documentation on this page: | ||
- [PHP-CS-Fixer: Config](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst) | ||
- [PHP-CS-Fixer: Rules](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/rules/index.rst) | ||
- [MLocati: PHP-CS-Fixer Configurator](https://mlocati.github.io/php-cs-fixer-configurator) | ||
|
||
|
||
```php | ||
<?php | ||
|
||
use PhpCsFixer\Finder; | ||
use Realodix\Relax\Config; | ||
|
||
// You can add or override rule set | ||
$localRules = [ | ||
// Add rule | ||
'array_syntax' => true, | ||
|
||
// Add rule or override predefined rule | ||
'visibility_required' => true, | ||
|
||
// Override predefined rule | ||
'braces' => false, | ||
|
||
// Add custom fixers | ||
'CustomFixer/rule_1' => true, | ||
'CustomFixer/rule_2' => true, | ||
]; | ||
|
||
$finder = Finder::create() | ||
->in(__DIR__) | ||
->ignoreDotFiles(false) | ||
->exclude(['Bar']) | ||
->notName('*.foo.php') | ||
->append(['.php-cs-fixer.dist.php']); | ||
|
||
return Config::create('laravel') | ||
->setRules($localRules) | ||
->setFinder($finder) | ||
->setRiskyAllowed(false) | ||
->registerCustomFixers(new \PhpCsFixerCustomFixers\CustomFixer()); | ||
``` | ||
|
||
If you wish to completely define rules locally without using existing rule sets, you can do that: | ||
|
||
```php | ||
<?php | ||
|
||
use Realodix\Relax\Config; | ||
|
||
$localRules = [ | ||
'@PSR2' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'ordered_imports' => ['sort_algorithm' => 'alpha'], | ||
]; | ||
|
||
return Config::create() | ||
->setRules($localRules); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters