|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +// ecs.php |
| 6 | +use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; |
| 7 | +use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; |
| 8 | +use PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer; |
| 9 | +use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer; |
| 10 | +use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; |
| 11 | +use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; |
| 12 | +use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer; |
| 13 | +use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer; |
| 14 | +use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer; |
| 15 | +use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; |
| 16 | +use Symplify\EasyCodingStandard\Config\ECSConfig; |
| 17 | +use Symplify\EasyCodingStandard\ValueObject\Set\SetList; |
| 18 | + |
| 19 | +return static function (ECSConfig $ecsConfig): void { |
| 20 | + // Parallel |
| 21 | + $ecsConfig->parallel(); |
| 22 | + |
| 23 | + $ecsConfig->cacheDirectory('.ecs-cache'); |
| 24 | + // Paths |
| 25 | + $ecsConfig->paths([ |
| 26 | + __DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php' |
| 27 | + ]); |
| 28 | + |
| 29 | + // A. full sets |
| 30 | + $ecsConfig->sets([SetList::PSR_12, SetList::SPACES]); |
| 31 | + |
| 32 | + $ecsConfig->rule(NotOperatorWithSuccessorSpaceFixer::class); |
| 33 | + $ecsConfig->rule(ArraySyntaxFixer::class); |
| 34 | + $ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [ |
| 35 | + 'annotations' => ['author', 'inheritdoc'] |
| 36 | + ]); |
| 37 | + $ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class); |
| 38 | + $ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [ |
| 39 | + 'allow_mixed' => true |
| 40 | + ]); |
| 41 | + $ecsConfig->rule(NoEmptyPhpdocFixer::class); |
| 42 | + $ecsConfig->rule(NoUnusedImportsFixer::class); |
| 43 | + $ecsConfig->rule(DeclareStrictTypesFixer::class); |
| 44 | + $ecsConfig->ruleWithConfiguration(FinalInternalClassFixer::class, [ |
| 45 | + 'annotation_exclude' => ['@not-fix', '@internal'], |
| 46 | + 'annotation_include' => [], |
| 47 | + 'consider_absent_docblock_as_internal_class' => \true |
| 48 | + ]); |
| 49 | + $ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [ |
| 50 | + 'forbiddenFunctions' => [ |
| 51 | + 'passthru' => null, |
| 52 | + 'var_dump' => null, |
| 53 | + ] |
| 54 | + ]); |
| 55 | + $ecsConfig->skip([ |
| 56 | + ForbiddenFunctionsSniff::class => [ |
| 57 | + 'tests/**', |
| 58 | + 'console/**' |
| 59 | + ] |
| 60 | + ]); |
| 61 | + |
| 62 | + // $ecsConfig->skip([ |
| 63 | + // FinalClassFixer::class => [ |
| 64 | + // 'tests/**' |
| 65 | + // ] |
| 66 | + // ]); |
| 67 | +}; |
0 commit comments