-
Notifications
You must be signed in to change notification settings - Fork 2
/
ecs.php
96 lines (82 loc) · 3.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
<?php
use PhpCsFixer\Fixer\Alias\ModernizeStrposFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
use PhpCsFixer\Fixer\ControlStructure\{NoUselessElseFixer, YodaStyleFixer};
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer;
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
use PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer;
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
/**
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/list.rst
* @see https://github.com/symplify/easy-coding-standard
*/
return function (ECSConfig $ecsConfig): void {
$ecsConfig->cacheDirectory(__DIR__.'/.ecs_cache');
$ecsConfig->parallel();
$ecsConfig->paths([
__DIR__.'/src',
]);
$ecsConfig->skip([
IsNullFixer::class,
MultilineWhitespaceBeforeSemicolonsFixer::class,
NativeFunctionInvocationFixer::class,
ReturnAssignmentFixer::class,
SingleLineCommentStyleFixer::class,
YodaStyleFixer::class,
PhpdocNoPackageFixer::class,
]);
$ecsConfig->sets([
SetList::PSR_12,
]);
$ecsConfig->rules([
NoUselessReturnFixer::class,
NoUselessElseFixer::class,
ModernizeStrposFixer::class,
NoUnusedImportsFixer::class,
NoSuperfluousPhpdocTagsFixer::class,
ReturnTypeDeclarationFixer::class,
]);
$ecsConfig->ruleWithConfiguration(ConcatSpaceFixer::class, [
'spacing' => 'none',
]);
$ecsConfig->ruleWithConfiguration(IncrementStyleFixer::class, [
'style' => 'post'
]);
$ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, [
'elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'one', 'trait_import' => 'only_if_meta'],
]);
$ecsConfig->ruleWithConfiguration(BlankLineBeforeStatementFixer::class, [
'statements' => ['if', 'break', 'continue', 'declare', 'return', 'throw', 'try', 'switch'],
]);
$ecsConfig->ruleWithConfiguration(BinaryOperatorSpacesFixer::class, [
'default' => 'align_single_space_minimal',
'operators' => [
'|' => 'no_space',
'/' => null,
'*' => null,
'||' => null,
'&&' => null,
],
]);
$header = <<<'EOF'
@author Aaron Scherer <[email protected]>
@date 2019
@license https://opensource.org/licenses/MIT
EOF;
$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
'header' => $header
]);
};