-
Notifications
You must be signed in to change notification settings - Fork 13
/
ecs.php
84 lines (78 loc) · 4.24 KB
/
ecs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff;
use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff;
use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff;
use PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff;
use PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\FileHeaderSniff;
use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\CastSpacingSniff;
use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionSpacingSniff;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use SlevomatCodingStandard\Sniffs\Arrays\TrailingArrayCommaSniff;
use SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff;
use SlevomatCodingStandard\Sniffs\Classes\ClassMemberSpacingSniff;
use SlevomatCodingStandard\Sniffs\Classes\ConstantSpacingSniff;
use SlevomatCodingStandard\Sniffs\Classes\EmptyLinesAroundClassBracesSniff;
use SlevomatCodingStandard\Sniffs\Classes\PropertySpacingSniff;
use SlevomatCodingStandard\Sniffs\Classes\RequireConstructorPropertyPromotionSniff;
use SlevomatCodingStandard\Sniffs\Classes\TraitUseDeclarationSniff;
use SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff;
use SlevomatCodingStandard\Sniffs\Functions\RequireTrailingCommaInCallSniff;
use SlevomatCodingStandard\Sniffs\Functions\RequireTrailingCommaInDeclarationSniff;
use SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff;
use SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff;
use SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff;
use SlevomatCodingStandard\Sniffs\PHP\OptimizedFunctionsWithoutUnpackingSniff;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(FileHeaderSniff::class);
$services->set(TraitUseDeclarationSniff::class);
$services->set(DisallowLongArraySyntaxSniff::class);
$services->set(DeclareStrictTypesFixer::class);
$services->set(UnusedUsesSniff::class);
$services->set(UseFromSameNamespaceSniff::class);
$services->set(OptimizedFunctionsWithoutUnpackingSniff::class);
$services->set(DeadCatchSniff::class);
$services->set(RequireTrailingCommaInCallSniff::class);
$services->set(RequireTrailingCommaInDeclarationSniff::class);
$services->set(RequireConstructorPropertyPromotionSniff::class);
$services->set(AlphabeticallySortedUsesSniff::class);
$services->set(ClassConstantVisibilitySniff::class);
$services->set(TrailingArrayCommaSniff::class);
$services->set(ArrayIndentSniff::class);
$services->set(ClassMemberSpacingSniff::class);
$services->set(CastSpacingSniff::class);
$services->set(SpaceAfterCastSniff::class);
$services->set(LineLengthSniff::class)
->property('absoluteLineLimit', 120);
$services->set(FunctionSpacingSniff::class)
->property('spacing', 1)
->property('spacingBeforeFirst', 0)
->property('spacingAfterLast', 0);
$services->set(PropertySpacingSniff::class)
->property('minLinesCountBeforeWithComment', 1)
->property('maxLinesCountBeforeWithComment', 1)
->property('minLinesCountBeforeWithoutComment', 0)
->property('maxLinesCountBeforeWithoutComment', 1);
$services->set(ConstantSpacingSniff::class)
->property('minLinesCountBeforeWithComment', 1)
->property('maxLinesCountBeforeWithComment', 1)
->property('minLinesCountBeforeWithoutComment', 0)
->property('maxLinesCountBeforeWithoutComment', 1);
$services->set(EmptyLinesAroundClassBracesSniff::class)
->property('linesCountAfterOpeningBrace', 0)
->property('linesCountBeforeClosingBrace', 0);
$services->set(BinaryOperatorSpacesFixer::class)
->call('configure', [
['default' => BinaryOperatorSpacesFixer::SINGLE_SPACE],
]);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__]);
$parameters->set(Option::SETS, [
SetList::PSR_12,
]);
};