-
Notifications
You must be signed in to change notification settings - Fork 28
/
.php-cs-fixer.php
149 lines (144 loc) · 5 KB
/
.php-cs-fixer.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 PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
$finder = Finder::create()
->files()
->in([
__DIR__ . '/bin',
__DIR__ . '/src',
__DIR__ . '/src/core/**/src',
__DIR__ . '/src/core/**/tests',
__DIR__ . '/src/adapter/**/src',
__DIR__ . '/src/bridge/**/**/src',
__DIR__ . '/src/adapter/**/tests',
__DIR__ . '/src/lib/**/src',
__DIR__ . '/src/lib/**/tests',
__DIR__ . '/web/**/src',
__DIR__ . '/web/**/tests',
__DIR__ . '/examples',
]);
if (!\file_exists(__DIR__ . '/var')) {
\mkdir(__DIR__ . '/var');
}
if (!\file_exists(__DIR__ . '/var/cs-fixer')) {
\mkdir(__DIR__ . '/var/cs-fixer');
}
return (new Config())
->setParallelConfig(ParallelConfigFactory::detect())
->setRiskyAllowed(true)
->setCacheFile(__DIR__ . '/var/cs-fixer/php_cs.cache')
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'blank_line_after_opening_tag' => true,
'group_import' => true,
'single_import_per_statement' => false,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'default',
'do',
'exit',
'for',
'foreach',
'goto',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
],
],
'blank_line_between_import_groups' => false,
'blank_lines_before_namespace' => false,
'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one']],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'fopen_flags' => true,
'heredoc_to_nowdoc' => true,
'increment_style' => ['style' => 'post'],
'linebreak_after_opening_tag' => false,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_types_casting' => false,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => false,
'native_function_invocation' => false,
'new_with_parentheses' => false,
'no_extra_blank_lines' => true, // todo?
'no_mixed_echo_print' => ['use' => 'print'],
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => false,
'no_unneeded_control_parentheses' => true, // todo?
'no_unreachable_default_argument_value' => true,
'no_unset_on_property' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'case',
'property_public_static',
'property_protected_static',
'property_private_static',
'property_public',
'property_protected',
'property_private',
'construct',
'method_public_static',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
'method_protected_static',
'method_private_static',
],
'sort_algorithm' => 'alpha'
],
'ordered_imports' => [
'imports_order' => [
'const',
'function',
'class',
],
'sort_algorithm' => 'alpha',
],
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'phpdoc_align' => ['align' => 'left'],
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_to_comment' => false,
'phpdoc_types_order' => true,
'protected_to_private' => true,
'return_assignment' => false,
'return_type_declaration' => ['space_before' => 'one'],
'self_static_accessor' => true,
'single_line_throw' => false,
'strict_param' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => false,
'void_return' => true,
'php_unit_method_casing' => ['case' => 'snake_case'],
'php_unit_test_case_static_method_calls' => ['call_type' => 'static'],
])
->setFinder($finder);