This repository has been archived by the owner on May 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.php_cs
286 lines (281 loc) · 9.32 KB
/
.php_cs
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php
use Symfony\CS\Config\Config;
use Symfony\CS\Finder\DefaultFinder;
use Symfony\CS\FixerInterface;
/*
* List of available fixers:
*
* "psr0" [PSR-0]
* Classes must be in a path that matches their namespace, be at least one namespace deep, and the class name should
* match the file name.
*
* "encoding" [PSR-1]
* PHP code MUST use only UTF-8 without BOM (remove BOM).
*
* "short_tag" [PSR-1]
* PHP code must use the long <?php ?> tags or the short-echo <?= ?> tags; it must not use the other tag variations.
*
* "braces" [PSR-2]
* The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be
* properly indented.
*
* "elseif" [PSR-2]
* The keyword elseif should be used instead of else if so that all control keywords looks like single words.
*
* "eof_ending" [PSR-2]
* A file must always end with an empty line feed.
*
* "function_call_space" [PSR-2]
* When making a method or function call, there MUST NOT be a space between the method or function name and the opening
* parenthesis.
*
* "function_declaration" [PSR-2]
* Spaces should be properly placed in a function declaration.
*
* "indentation" [PSR-2]
* Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting.
*
* "line_after_namespace" [PSR-2]
* There MUST be one blank line after the namespace declaration.
*
* "linefeed" [PSR-2]
* All PHP files must use the Unix LF (linefeed) line ending.
*
* "lowercase_constants" [PSR-2]
* The PHP constants true, false, and null MUST be in lower case.
*
* "lowercase_keywords" [PSR-2]
* PHP keywords MUST be in lower case.
*
* "method_argument_space" [PSR-2]
* In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after
* each comma.
*
* "multiple_use" [PSR-2]
* There MUST be one use keyword per declaration.
*
* "parenthesis" [PSR-2]
* There MUST NOT be a space after the opening parenthesis. There MUST NOT be a space before the closing parenthesis.
*
* "php_closing_tag" [PSR-2]
* The closing ?> tag MUST be omitted from files containing only PHP.
*
* "single_line_after_imports" [PSR-2] Each namespace use MUST go on its own line and there MUST be one blank line after
* the use statements block.
*
* "trailing_spaces" [PSR-2]
* Remove trailing whitespace at the end of non-blank lines.
*
* "visibility" [PSR-2]
* Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility;
* static MUST be declared after the visibility.
*
* "concat_without_spaces" [symfony]
* Concatenation should be used without spaces.
*
* "double_arrow_multiline_whitespaces" [symfony]
* Operator => should not be surrounded by multi-line whitespaces.
*
* "duplicate_semicolon" [symfony]
* Remove duplicated semicolons.
*
* "empty_return" [symfony]
* A return statement wishing to return nothing should be simply "return".
*
* "extra_empty_lines" [symfony]
* Removes extra empty lines.
*
* "include" [symfony]
* Include and file path should be divided with a single space. File path should not be placed under brackets.
*
* "join_function" [symfony]
* Implode function should be used instead of join function.
*
* "multiline_array_trailing_comma" [symfony]
* PHP multi-line arrays should have a trailing comma.
*
* "namespace_no_leading_whitespace" [symfony]
* The namespace declaration line shouldn't contain leading whitespace.
*
* "new_with_braces" [symfony]
* All instances created with new keyword must be followed by braces.
*
* "no_blank_lines_after_class_opening" [symfony]
* There should be no empty lines after class opening brace.
*
* "no_empty_lines_after_phpdocs" [symfony]
* There should not be blank lines between docblock and the documented element.
*
* "object_operator" [symfony]
* There should not be space before or after object T_OBJECT_OPERATOR.
*
* "operators_spaces" [symfony]
* Operators should be surrounded by at least one space.
*
* "phpdoc_indent" [symfony]
* Docblocks should have the same indentation as the documented subject.
*
* "phpdoc_no_empty_return" [symfony]
* @return void and @return null annotations should be omitted from phpdocs.
*
* "phpdoc_no_package" [symfony]
* @package and @subpackage annotations should be omitted from phpdocs.
*
* "phpdoc_params" [symfony]
* All items of the @param, @throws, @return, @var, and @type phpdoc tags must be aligned vertically.
*
* "phpdoc_separation" [symfony]
* Annotations in phpdocs should be grouped together so that annotations of the same type immediately follow each other,
* and annotations of a different type are separated by a single blank line.
*
* "phpdoc_short_description" [symfony]
* Phpdocs short descriptions should end in either a full stop, exclamation mark, or question mark.
*
* "phpdoc_to_comment" [symfony]
* Docblocks should only be used on structural elements.
*
* "phpdoc_trim" [symfony]
* Phpdocs should start and end with content, excluding the very fist and last line of the docblocks.
*
* "phpdoc_type_to_var" [symfony]
* @type should always be written as @var.
*
* "phpdoc_var_without_name" [symfony]
* @var and @type annotations should not contain the variable name.
*
* "remove_leading_slash_use" [symfony]
* Remove leading slashes in use clauses.
*
* "remove_lines_between_uses" [symfony]
* Removes line breaks between use statements.
*
* "return" [symfony]
* An empty line feed should precede a return statement.
*
* "single_array_no_trailing_comma" [symfony]
* PHP single-line arrays should not have trailing comma.
*
* "single_blank_line_before_namespace" [symfony]
* There should be exactly one blank line before a namespace declaration.
*
* "spaces_before_semicolon" [symfony]
* Single-line whitespace before closing semicolon are prohibited.
*
* "spaces_cast" [symfony]
* A single space should be between cast and variable.
*
* "standardize_not_equal" [symfony]
* Replace all <> with !=.
*
* "ternary_spaces" [symfony]
* Standardize spaces around ternary operator.
*
* "unused_use" [symfony]
* Unused use statements must be removed.
*
* "whitespacy_lines" [symfony]
* Remove trailing whitespace at the end of blank lines.
*
* "align_double_arrow" [contrib]
* Align double arrow symbols in consecutive lines.
*
* "align_equals" [contrib]
* Align equals symbols in consecutive lines.
*
* "concat_with_spaces" [contrib]
* Concatenation should be used with at least one whitespace around.
*
* "ereg_to_preg" [contrib]
* Replace deprecated ereg regular expression functions with preg. Warning! This could change code behavior.
*
* "header_comment" [contrib]
* Add, replace or remove header comment.
*
* "multiline_spaces_before_semicolon" [contrib]
* Multi-line whitespace before closing semicolon are prohibited.
*
* "no_blank_lines_before_namespace" [contrib]
* There should be no blank lines before a namespace declaration.
*
* "ordered_use" [contrib]
* Ordering use statements.
*
* "php4_constructor" [contrib]
* Convert PHP4-style constructors to __construct. Warning! This could change code behavior.
*
* "phpdoc_order" [contrib]
* Annotations in phpdocs should be ordered so that param annotations come first, then throws annotations, then
* return annotations.
*
* "phpdoc_var_to_type" [contrib]
* @var should always be written as @type.
*
* "short_array_syntax" [contrib]
* PHP array's should use the PHP 5.4 short-syntax.
*
* "strict" [contrib]
* Comparison should be strict. Warning! This could change code behavior.
*
* "strict_param" [contrib]
* Functions should be used with $strict param. Warning! This could change code behavior.
*/
// Files and directories that will be scanned
$finder = DefaultFinder::create()
->exclude([
'data',
'db',
'public',
'vendor',
])
->in([
'mot-api',
'mot-common-web-module',
'mot-web-frontend',
]);
// CS issues to fix
$config = Config::create()
->level(FixerInterface::PSR2_LEVEL)
->fixers(
[
'concat_with_spaces',
'double_arrow_multiline_whitespaces',
'duplicate_semicolon',
'extra_empty_lines',
'include',
'join_function',
'multiline_array_trailing_comma',
'multiline_spaces_before_semicolon',
'namespace_no_leading_whitespace',
'new_with_braces',
'no_blank_lines_after_class_opening',
'object_operator',
'operators_spaces',
'ordered_use',
'phpdoc_indent',
'phpdoc_no_empty_return',
'phpdoc_no_package',
'phpdoc_order',
'phpdoc_params',
'phpdoc_separation',
'phpdoc_short_description',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_type_to_var',
'phpdoc_var_without_name',
'remove_leading_slash_use',
'remove_lines_between_uses',
'return',
'short_array_syntax',
'single_array_no_trailing_comma',
'single_blank_line_before_namespace',
'spaces_before_semicolon',
'spaces_cast',
'standardize_not_equal',
'ternary_spaces',
'trailing_spaces',
'unused_use',
'whitespacy_lines',
])
->finder($finder)
->setUsingCache(true);
return $config;