-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
ecs.php
90 lines (79 loc) · 3.63 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
85
86
87
88
89
90
<?php
declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff;
use PhpCsFixer\Fixer\Alias\RandomApiMigrationFixer;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer;
use PhpCsFixer\Fixer\FunctionNotation\NoSpacesAfterFunctionNameFixer;
use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer;
use PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\TernaryToNullCoalescingFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
use SlevomatCodingStandard\Sniffs\Classes\ParentCallSpacingSniff;
use SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff;
use SlevomatCodingStandard\Sniffs\Namespaces\UselessAliasSniff;
use SlevomatCodingStandard\Sniffs\PHP\UselessSemicolonSniff;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]]);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/app',
__DIR__ . '/tests',
]);
// Namespaces
$services->set(UselessAliasSniff::class);
$services->set(NoUnusedImportsFixer::class);
$services->set(OrderedImportsFixer::class);
$services->set(SingleBlankLineBeforeNamespaceFixer::class);
$services->set(ParentCallSpacingSniff::class);
$services->set(UselessSemicolonSniff::class);
$services->set(NoWhitespaceBeforeCommaInArrayFixer::class);
$services->set(GitMergeConflictSniff::class);
$services->set(TrimArraySpacesFixer::class);
$services->set(TrailingCommaInMultilineArrayFixer::class);
$services->set(NoTrailingCommaInSinglelineArrayFixer::class);
// PHP 7.1
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]]);
$services->set(RandomApiMigrationFixer::class)
->call('configure', [[
'mt_rand' => 'random_int',
'rand' => 'random_int',
]]);
$services->set(TernaryToNullCoalescingFixer::class);
$services->set(BlankLineAfterStrictTypesFixer::class);
$services->set(DeclareEqualNormalizeFixer::class);
$services->set(ReturnTypeDeclarationFixer::class);
$services->set(ReferenceThrowableOnlySniff::class);
$services->set(ArrayIndentationFixer::class);
$services->set(NoSpacesAfterFunctionNameFixer::class);
$parameters->set(Option::SETS, [
SetList::CONTROL_STRUCTURES,
SetList::PSR_12,
SetList::PHP_71,
SetList::PHP_73_MIGRATION,
]);
$services->set(BinaryOperatorSpacesFixer::class)
->call('configure', [[
'align_double_arrow' => true,
'align_equals' => true,
]]);
};