forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs.php
149 lines (140 loc) · 7.21 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff;
use PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer;
use PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer;
use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer;
use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer;
use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer;
use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer;
use PhpCsFixer\Fixer\LanguageConstruct\ExplicitIndirectVariableFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockShortWillReturnFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer;
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypehintFixer;
use PhpCsFixerCustomFixers\Fixer\NoImportFromGlobalNamespaceFixer;
use PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer;
use PhpCsFixerCustomFixers\Fixer\NoUselessCommentFixer;
use PhpCsFixerCustomFixers\Fixer\NoUselessParenthesisFixer;
use PhpCsFixerCustomFixers\Fixer\NoUselessStrlenFixer;
use PhpCsFixerCustomFixers\Fixer\PhpdocTypesCommaSpacesFixer;
use PhpCsFixerCustomFixers\Fixer\SingleSpaceAfterStatementFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer;
use Symplify\CodingStandard\Fixer\Spacing\StandaloneLineConstructorParamFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->dynamicSets([
'@Symfony',
'@Symfony:risky',
]);
$ecsConfig->sets([
SetList::ARRAY,
SetList::CONTROL_STRUCTURES,
SetList::STRICT,
SetList::PSR_12,
]);
$ecsConfig->rules([
ModernizeTypesCastingFixer::class,
NativeConstantInvocationFixer::class,
NullableTypeDeclarationForDefaultNullValueFixer::class,
VoidReturnFixer::class,
OperatorLinebreakFixer::class,
PhpdocLineSpanFixer::class,
PhpUnitConstructFixer::class,
PhpUnitDedicateAssertInternalTypeFixer::class,
PhpUnitMockFixer::class,
PhpUnitMockShortWillReturnFixer::class,
PhpUnitTestCaseStaticMethodCallsFixer::class,
NoUselessReturnFixer::class,
DeclareStrictTypesFixer::class,
BlankLineBeforeStatementFixer::class,
CompactNullableTypehintFixer::class,
NoImportFromGlobalNamespaceFixer::class,
NoSuperfluousConcatenationFixer::class,
NoUselessCommentFixer::class,
SingleSpaceAfterStatementFixer::class,
NoUselessParenthesisFixer::class,
NoUselessStrlenFixer::class,
PhpdocTypesCommaSpacesFixer::class,
StandaloneLineConstructorParamFixer::class,
]);
$ecsConfig->ruleWithConfiguration(PhpdocAlignFixer::class, ['align' => 'left']);
$ecsConfig->ruleWithConfiguration(PhpdocOrderFixer::class, ['order' => ['param', 'throws', 'return']]);
$ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, ['elements' => ['property' => 'one', 'method' => 'one']]);
$ecsConfig->ruleWithConfiguration(MethodArgumentSpaceFixer::class, ['on_multiline' => 'ensure_fully_multiline']);
$ecsConfig->ruleWithConfiguration(NativeFunctionInvocationFixer::class, [
'include' => [NativeFunctionInvocationFixer::SET_COMPILER_OPTIMIZED],
'scope' => 'namespaced',
'strict' => false,
'exclude' => ['ini_get'],
]);
$ecsConfig->ruleWithConfiguration(ConcatSpaceFixer::class, ['spacing' => 'one']);
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, ['annotations' => ['copyright', 'category']]);
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, ['allow_unused_params' => true, 'allow_mixed' => true]);
$ecsConfig->ruleWithConfiguration(PhpUnitDedicateAssertFixer::class, ['target' => 'newest']);
$ecsConfig->ruleWithConfiguration(SingleQuoteFixer::class, ['strings_containing_single_quote_chars' => true]);
// workaround for https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/5495
$ecsConfig->ruleWithConfiguration(BinaryOperatorSpacesFixer::class, [
'operators' => [
'|' => null,
'&' => null,
],
]);
$ecsConfig->cacheDirectory($_SERVER['SHOPWARE_TOOL_CACHE_ECS'] ?? 'var/cache/cs_fixer');
$ecsConfig->cacheNamespace('platform');
$ecsConfig->parallel();
$ecsConfig->lineEnding('\n');
$ecsConfig->skip([
// Fixture
'src/WebInstaller/Tests/_fixtures/Options.php',
// skip php files in node modules (stylelint ships both js and php)
'**/node_modules',
ArrayOpenerAndCloserNewlineFixer::class => null,
ArrayListItemNewlineFixer::class => null,
SingleLineThrowFixer::class => null,
SelfAccessorFixer::class => null,
ExplicitIndirectVariableFixer::class => null,
BlankLineAfterOpeningTagFixer::class => null,
PhpdocSummaryFixer::class => null,
ExplicitStringVariableFixer::class => null,
StandaloneLineInMultilineArrayFixer::class => null,
AssignmentInConditionSniff::class => null,
PhpdocToCommentFixer::class => null,
PhpdocAnnotationWithoutDotFixer::class => null,
PhpdocNoPackageFixer::class => null,
StandaloneLineConstructorParamFixer::class => null,
LinebreakAfterOpeningTagFixer::class => null,
FopenFlagsFixer::class => null,
]);
};