diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 946e1bf..6ed2379 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use PhpCsFixer\Config; use PhpCsFixer\Finder; # PHP CS Fixer can be run by using the composer script `composer format` @@ -18,57 +17,4 @@ ->exclude('build') ; -return (new Config) - ->setFinder($finder) - ->setRules([ - '@PSR2' => true, - 'indentation_type' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sort_algorithm' => 'alpha', - ], - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => true, - 'logical_operators' => true, - 'trailing_comma_in_multiline' => true, - 'phpdoc_scalar' => true, - 'phpdoc_var_without_name' => true, - 'phpdoc_single_line_var_spacing' => true, - 'unary_operator_spaces' => true, - 'phpdoc_trim' => true, - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'align_multiline_comment' => true, - 'array_indentation' => true, - 'no_superfluous_elseif' => true, - 'single_blank_line_before_namespace' => true, - 'blank_line_after_opening_tag' => true, - 'no_blank_lines_after_phpdoc' => true, - 'phpdoc_separation' => true, - 'method_chaining_indentation' => true, - 'binary_operator_spaces' => [ - 'default' => 'single_space', - 'operators' => [ - '=>' => null, - '|' => 'no_space', - ], - ], - 'return_type_declaration' => [ - 'space_before' => 'none', - ], - 'blank_line_before_statement' => [ - 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], - ], - 'full_opening_tag' => true, - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'yoda_style' => [ - 'always_move_variable' => true, - 'equal' => true, - 'identical' => true, - 'less_and_greater' => true, - ], - 'declare_strict_types' => true, - ]) - ->setLineEnding("\n") - ->setRiskyAllowed(true); +return \Yard\PhpCsFixerRules\Config::create($finder); diff --git a/README.md b/README.md index b60f0f2..658d4f4 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ To install this package using Composer, follow these steps: ## Usage +Simple example: ```php exclude('build') ; -return \Yard\PhpCsFixerRules\Config::setFinder($finder) - ->mergeRules([ // allows you to add new rules or override rules from default - 'declare_strict_types' => false, +return \Yard\PhpCsFixerRules\Config::create($finder); +``` + +More complex: +```php +in(__DIR__) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true) + ->exclude('public') + ->exclude('node_modules') + ->exclude('build') +; + +return \Yard\PhpCsFixerRules\Config::create($finder) + ->mergeRules([ + 'yoda_style' => [ + 'equal' => false, + ], ]) - ->setRiskyAllowed(false) // override and disable risky setting for old projects - ->get(); + ->removeRule('declare_strict_types') + ->removeRules(['no_unused_imports', 'trailing_comma_in_multiline']) + ->setRiskyAllowed(false); // disable this for old sites! ``` + diff --git a/tests/Pest.php b/tests/Pest.php index b3d9bbc..174d7fd 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1 +1,3 @@