-
Notifications
You must be signed in to change notification settings - Fork 17
/
ecs.php
130 lines (123 loc) · 4.43 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
declare(strict_types=1);
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer;
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use PhpCsFixer\Fixer\Whitespace\HeredocIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
$ecsConfig->sets([SetList::PSR_12, SetList::CLEAN_CODE, SetList::COMMON]);
$ruleConfigurations = [
[
IncrementStyleFixer::class,
['style' => 'post'],
],
[
YodaStyleFixer::class,
[
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
],
[
ConcatSpaceFixer::class,
['spacing' => 'one'],
],
[
CastSpacesFixer::class,
['space' => 'none'],
],
[
OrderedImportsFixer::class,
['imports_order' => ['class', 'function', 'const']],
],
[
NoSuperfluousPhpdocTagsFixer::class,
[
'remove_inheritdoc' => false,
'allow_mixed' => true,
'allow_unused_params' => false,
],
],
[
DeclareEqualNormalizeFixer::class,
['space' => 'none'],
],
[
BlankLineBeforeStatementFixer::class,
['statements' => ['continue', 'declare', 'return', 'throw', 'try']],
],
[
BinaryOperatorSpacesFixer::class,
['operators' => ['&' => 'align']],
],
[
// https://github.com/nunomaduro/phpinsights/blob/master/docs/insights/style.md#no-extra-blank-lines---
NoExtraBlankLinesFixer::class,
[
'tokens' =>
[
'break',
'case',
'continue',
'curly_brace_block',
'default',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'switch',
'throw',
//'use',
'use_trait',
],
],
],
[
ClassDefinitionFixer::class,
[
'multi_line_extends_each_single_line' => true,
],
],
];
array_map(static fn ($parameters) => $ecsConfig->ruleWithConfiguration(...$parameters), $ruleConfigurations);
$ecsConfig->skip([
NoMultilineWhitespaceAroundDoubleArrowFixer::class => null,
PhpdocNoPackageFixer::class => null,
PhpdocSummaryFixer::class => null,
PhpdocSeparationFixer::class => null,
BlankLineAfterOpeningTagFixer::class => null,
ClassAttributesSeparationFixer::class => null,
NotOperatorWithSuccessorSpaceFixer::class => null,
SingleLineThrowFixer::class => null,
PhpdocAlignFixer::class => null,
HeredocIndentationFixer::class => null,
PhpdocToCommentFixer::class => null,
NativeFunctionInvocationFixer::class => null,
]);
};