-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs.php
92 lines (86 loc) · 3.7 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
<?php
declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff;
use PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff;
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PhpCsFixer\Fixer\ClassNotation\FinalClassFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff;
use SlevomatCodingStandard\Sniffs\Classes\ClassStructureSniff;
use SlevomatCodingStandard\Sniffs\Classes\MethodSpacingSniff;
use SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff;
use SlevomatCodingStandard\Sniffs\Functions\StaticClosureSniff;
use SlevomatCodingStandard\Sniffs\Functions\StrictCallSniff;
use SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff;
use SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff;
use SlevomatCodingStandard\Sniffs\Namespaces\UselessAliasSniff;
use SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff;
use SlevomatCodingStandard\Sniffs\Variables\DisallowSuperGlobalVariableSniff;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
// Sets have a combination of rules
$ecsConfig->sets([
SetList::CLEAN_CODE,
SetList::PSR_12,
]);
// Rules with a configuration (can be needed or to change the defaults)
$ecsConfig->ruleWithConfiguration(UnusedUsesSniff::class, [
'searchAnnotations' => true,
]);
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class,
[
'forbiddenFunctions' => [
'sizeof' => 'count', //keep the default option
'delete' => 'unset', //keep the default option
'dump' => null, //debug statement
'dd' => null, //debug statement
'var_dump' => null, //debug statement
'print_r' => null, //debug statement
'exit' => null, //this means we also skip the middleware
]
])
;
$ecsConfig->ruleWithConfiguration(ClassStructureSniff::class, [
'groups' => [
'uses',
'constants',
'enum cases',
'properties',
'constructor',
'static constructors',
'destructor',
'magic methods',
'all public methods',
'all protected methods',
'all private methods',
],
]);
$ecsConfig->ruleWithConfiguration(ReferenceUsedNamesOnlySniff::class, [
'searchAnnotations' => true,
'allowFullyQualifiedNameForCollidingClasses' => true,
]);
// Rules without config (defaults are good)
$ecsConfig->rule(ArrayIndentSniff::class);
$ecsConfig->rule(SpaceAfterCastSniff::class);
$ecsConfig->rule(StaticClosureSniff::class);
$ecsConfig->rule(DisallowSuperGlobalVariableSniff::class);
$ecsConfig->rule(ClassConstantVisibilitySniff::class);
$ecsConfig->rule(DeclareStrictTypesFixer::class);
$ecsConfig->rule(NoExtraBlankLinesFixer::class);
$ecsConfig->rule(FinalClassFixer::class);
$ecsConfig->rule(MethodSpacingSniff::class);
$ecsConfig->rule(UselessAliasSniff::class);
$ecsConfig->rule(EmptyCommentSniff::class);
$ecsConfig->rule(UseSpacingSniff::class);
$ecsConfig->rule(StrictCallSniff::class);
$ecsConfig->rule(PhpUnitConstructFixer::class);
$ecsConfig->rule(PhpUnitDedicateAssertFixer::class);
};