|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
5 | 5 | use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; |
| 6 | +use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer; |
| 7 | +use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer; |
| 8 | +use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer; |
| 9 | +use PhpCsFixer\Fixer\ClassNotation\FinalClassFixer; |
| 10 | +use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer; |
6 | 11 | use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer; |
| 12 | +use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer; |
| 13 | +use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer; |
| 14 | +use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer; |
| 15 | +use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer; |
7 | 16 | use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; |
8 | 17 | use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; |
9 | 18 | use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer; |
| 19 | +use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer; |
10 | 20 | use Symplify\EasyCodingStandard\Config\ECSConfig; |
11 | | -use Symplify\EasyCodingStandard\ValueObject\Set\SetList; |
12 | 21 |
|
13 | | -return function (ECSConfig $ecsConfig): void { |
14 | | - $ecsConfig->paths([ |
| 22 | +return ECSConfig::configure() |
| 23 | + ->withPaths([ |
15 | 24 | __DIR__ . '/src', |
16 | 25 | __DIR__ . '/tests', |
17 | | - ]); |
18 | | - |
19 | | - $ecsConfig->sets([ |
20 | | - SetList::ARRAY, |
21 | | - SetList::DOCBLOCK, |
22 | | - SetList::NAMESPACES, |
23 | | - SetList::COMMENTS, |
24 | | - SetList::STRICT, |
25 | | - SetList::PSR_12, |
26 | | - ]); |
27 | | - |
28 | | - $ecsConfig->skip([ |
29 | | - /* Do not force array on multiple lines : ['foo' => $foo, 'bar' => $bar] */ |
30 | | - ArrayOpenerAndCloserNewlineFixer::class, |
31 | | - ArrayListItemNewlineFixer::class, |
32 | | - StandaloneLineInMultilineArrayFixer::class, |
33 | | - ]); |
34 | | - |
35 | | - $ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [ |
| 26 | + ]) |
| 27 | + ->withPhpCsFixerSets( |
| 28 | + // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/ruleSets/PER-CS2.0.rst |
| 29 | + perCS20: true, |
| 30 | + ) |
| 31 | + ->withPreparedSets( |
| 32 | + arrays: true, |
| 33 | + comments: true, |
| 34 | + docblocks: true, |
| 35 | + namespaces: true, |
| 36 | + phpunit: true, |
| 37 | + strict: true, |
| 38 | + ) |
| 39 | + ->withRules([ |
| 40 | + FinalClassFixer::class, |
| 41 | + ]) |
| 42 | + ->withConfiguredRule(BlankLineBeforeStatementFixer::class, [ |
| 43 | + 'statements' => ['case', 'continue', 'declare', 'default', 'return', 'throw', 'try'], |
| 44 | + ]) |
| 45 | + ->withConfiguredRule(CastSpacesFixer::class, [ |
| 46 | + 'space' => 'none', |
| 47 | + ]) |
| 48 | + ->withConfiguredRule(ForbiddenFunctionsSniff::class, [ |
36 | 49 | 'forbiddenFunctions' => ['dump' => null, 'dd' => null, 'var_dump' => null, 'die' => null], |
37 | | - ]); |
38 | | - $ecsConfig->ruleWithConfiguration(FunctionDeclarationFixer::class, [ |
| 50 | + ]) |
| 51 | + ->withConfiguredRule(FunctionDeclarationFixer::class, [ |
39 | 52 | 'closure_fn_spacing' => 'none', |
40 | | - ]); |
41 | | -}; |
| 53 | + ]) |
| 54 | + ->withConfiguredRule(LineLengthFixer::class, [ |
| 55 | + LineLengthFixer::INLINE_SHORT_LINES => false, |
| 56 | + ]) |
| 57 | + ->withConfiguredRule(NativeFunctionInvocationFixer::class, [ |
| 58 | + 'scope' => 'namespaced', |
| 59 | + 'include' => ['@all'], |
| 60 | + ]) |
| 61 | + ->withConfiguredRule(NullableTypeDeclarationFixer::class, [ |
| 62 | + 'syntax' => 'union', |
| 63 | + ]) |
| 64 | + ->withConfiguredRule(YodaStyleFixer::class, [ |
| 65 | + 'equal' => false, |
| 66 | + 'identical' => false, |
| 67 | + 'less_and_greater' => false, |
| 68 | + ]) |
| 69 | + ->withConfiguredRule(ClassDefinitionFixer::class, [ |
| 70 | + 'inline_constructor_arguments' => false, |
| 71 | + 'space_before_parenthesis' => false, |
| 72 | + ]) |
| 73 | + ->withSkip([ |
| 74 | + ArrayListItemNewlineFixer::class, |
| 75 | + ArrayOpenerAndCloserNewlineFixer::class, |
| 76 | + ExplicitStringVariableFixer::class, |
| 77 | + SingleLineEmptyBodyFixer::class, |
| 78 | + StandaloneLineInMultilineArrayFixer::class, |
| 79 | + FinalClassFixer::class => [ |
| 80 | + 'src/Entity/', |
| 81 | + ], |
| 82 | + ]) |
| 83 | +; |
0 commit comments