-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathecs.php
81 lines (77 loc) · 3.03 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
<?php
declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer;
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer;
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
$composer = \json_decode(\file_get_contents(__DIR__.'/composer.json'), true);
return ECSConfig::configure()
->withPaths(\array_map(
fn(string $path) => __DIR__ . '/' . $path,
[
...\array_values($composer['autoload']['psr-4']),
...\array_values($composer['autoload-dev']['psr-4']),
]
))
->withPhpCsFixerSets(
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/ruleSets/PER-CS2.0.rst
perCS20: true,
)
->withPreparedSets(
arrays: true,
comments: true,
docblocks: true,
namespaces: true,
phpunit: true,
strict: true,
)
->withConfiguredRule(BlankLineBeforeStatementFixer::class, [
'statements' => ['case', 'continue', 'declare', 'default', 'return', 'throw', 'try'],
])
->withConfiguredRule(CastSpacesFixer::class, [
'space' => 'none',
])
->withConfiguredRule(ForbiddenFunctionsSniff::class, [
'forbiddenFunctions' => ['dump' => null, 'dd' => null, 'var_dump' => null, 'die' => null],
])
->withConfiguredRule(FunctionDeclarationFixer::class, [
'closure_fn_spacing' => 'none',
])
->withConfiguredRule(LineLengthFixer::class, [
LineLengthFixer::INLINE_SHORT_LINES => false,
])
->withConfiguredRule(NativeFunctionInvocationFixer::class, [
'scope' => 'namespaced',
'include' => ['@all'],
])
->withConfiguredRule(NullableTypeDeclarationFixer::class, [
'syntax' => 'union',
])
->withConfiguredRule(YodaStyleFixer::class, [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
])
->withConfiguredRule(ClassDefinitionFixer::class, [
'inline_constructor_arguments' => false,
'space_before_parenthesis' => false,
])
->withSkip([
SingleLineEmptyBodyFixer::class,
ArrayListItemNewlineFixer::class,
ArrayOpenerAndCloserNewlineFixer::class,
ExplicitStringVariableFixer::class,
StandaloneLineInMultilineArrayFixer::class,
])
;