-
Notifications
You must be signed in to change notification settings - Fork 4
/
.php-cs-fixer.php
251 lines (181 loc) · 7.42 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->exclude('storage')
->exclude('vendor')
->exclude('node_modules');
return (new Config())
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
// Applies PSR-12 coding style standard
'@PSR12' => true,
// Uses short array syntax []
'array_syntax' => ['syntax' => 'short'],
// Ensures arrays are indented correctly
'array_indentation' => true,
// Aligns binary operators for readability
'binary_operator_spaces' => [
'default' => 'single_space',
],
// Ensures blank line after namespace
'blank_line_after_namespace' => true,
// Ensures blank line after opening PHP tag
'blank_line_after_opening_tag' => true,
// Ensures blank line before return statements
'blank_line_before_statement' => [
'statements' => ['return'],
],
// Controls brace placement, allows single-line closures
'braces' => [
'allow_single_line_closure' => true,
],
// Ensures single space after type casts
'cast_spaces' => ['space' => 'single'],
// Adds blank line between class methods and properties
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
'property' => 'one',
],
],
// Ensures single space around concatenation operators
'concat_space' => ['spacing' => 'one'],
// Adds strict types declaration
'declare_strict_types' => true,
// Controls function declaration spacing
'function_declaration' => ['closure_function_spacing' => 'none'],
// Ensures space between function typehint and parameter
'function_typehint_space' => true,
// Enforces parentheses for include and require
'include' => true,
// Enforces post-increment/decrement style
'increment_style' => ['style' => 'post'],
// Ensures files end with a newline
'line_ending' => true,
// Enforces lowercase casting
'lowercase_cast' => true,
// Ensures correct casing for magic methods
'magic_method_casing' => true,
// Controls spacing around method arguments
'method_argument_space' => [
'on_multiline' => 'ignore',
],
// Ensures native function calls are correctly cased
'native_function_casing' => true,
// Ensures no blank lines after class opening
'no_blank_lines_after_class_opening' => true,
// Ensures no blank lines after PHPDoc
'no_blank_lines_after_phpdoc' => true,
// Ensures no closing PHP tag
'no_closing_tag' => true,
// Removes empty PHPDoc blocks
'no_empty_phpdoc' => true,
// Removes unnecessary empty statements
'no_empty_statement' => true,
// Removes extra blank lines
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
'use_trait',
'curly_brace_block',
'parenthesis_brace_block',
'square_brace_block',
],
],
// Ensures no leading slash in use statements
'no_leading_import_slash' => true,
// Ensures no whitespace before namespace
'no_leading_namespace_whitespace' => true,
// Consistently uses echo instead of print
'no_mixed_echo_print' => ['use' => 'echo'],
// Ensures no whitespace around multi-line array arrows
'no_multiline_whitespace_around_double_arrow' => true,
// Ensure multi-line whitespace before semicolons
'multiline_whitespace_before_semicolons' => true,
// Disallows short boolean casting
'no_short_bool_cast' => true,
// Removes whitespace before semicolons
'no_singleline_whitespace_before_semicolons' => true,
// Ensures no spaces around array offsets
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
// Removes trailing commas in single-line arrays
'no_trailing_comma_in_singleline' => true,
// Removes trailing whitespace
'no_trailing_whitespace' => true,
// Removes trailing whitespace in comments
'no_trailing_whitespace_in_comment' => true,
// Removes unused imports
'no_unused_imports' => true,
// Removes unnecessary return statements
'no_useless_return' => true,
// Ensures no whitespace before commas in arrays
'no_whitespace_before_comma_in_array' => true,
// Removes whitespace in blank lines
'no_whitespace_in_blank_line' => true,
// Standardizes array index braces
'normalize_index_brace' => true,
// Sorts imports alphabetically
'ordered_imports' => ['sort_algorithm' => 'alpha'],
// Aligns PHPDoc tags
'phpdoc_align' => false,
// Ensures PHPDoc indentation
'phpdoc_indent' => true,
// Removes @access tags from PHPDoc
'phpdoc_no_access' => true,
// Removes @package tags from PHPDoc
'phpdoc_no_package' => true,
// Removes useless @inheritdoc tags
'phpdoc_no_useless_inheritdoc' => true,
// Enforces lowercase scalar types in PHPDoc
'phpdoc_scalar' => true,
// Ensures spacing in single-line @var PHPDoc annotations
'phpdoc_single_line_var_spacing' => true,
// Disables enforcing period at end of PHPDoc summary
'phpdoc_summary' => false,
// Disables conversion of PHPDoc to regular comments
'phpdoc_to_comment' => false,
// Trims blank lines in PHPDoc
'phpdoc_trim' => true,
// Ensures correct formatting of types in PHPDoc
'phpdoc_types' => true,
// Ensures semicolons after instructions
'semicolon_after_instruction' => true,
// Ensures single blank line at the end of file
'single_blank_line_at_eof' => true,
// Enforces one property per statement
'single_class_element_per_statement' => ['elements' => ['property']],
// Ensures one import per statement
'single_import_per_statement' => true,
// Ensures single blank line after imports
'single_line_after_imports' => true,
// Enforces single quotes for strings where possible
'single_quote' => true,
// Ensures space after semicolons in for loops
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
// Enforces !== and === instead of <>
'standardize_not_equals' => true,
// Ensures spaces around ternary operators
'ternary_operator_spaces' => true,
// Removes spaces inside array brackets
'trim_array_spaces' => true,
// Ensures correct spacing for unary operators
'unary_operator_spaces' => true,
// Ensures whitespace after commas in arrays
'whitespace_after_comma_in_array' => true,
// Ensures yoda-style conditions (e.g. 1 === $foo) are reversed (e.g. $foo === 1)
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
])
->setFinder($finder);