1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * PHP Code Style Fixer (config created for version 3.6.0 (Roe Deer)). |
||
7 | * |
||
8 | * Use one of the following console commands to just see the |
||
9 | * changes that will be made. |
||
10 | * - `php-cs-fixer fix --config='.php-cs-fixer.php' --dry-run` |
||
11 | * - `php '.php-cs-fixer.php'` |
||
12 | * - `php7.1 '.php-cs-fixer.php'` |
||
13 | * - `php7.2 '.php-cs-fixer.php'` |
||
14 | * - `php7.3 '.php-cs-fixer.php'` |
||
15 | * - `php7.4 '.php-cs-fixer.php'` |
||
16 | * - `php8.0 '.php-cs-fixer.php'` |
||
17 | * |
||
18 | * Use one of the following console commands to fix PHP code: |
||
19 | * - `php-cs-fixer fix --config='.php-cs-fixer.php' |
||
20 | * - `php '.php-cs-fixer.php' --force` |
||
21 | * - `php7.1 '.php-cs-fixer.php' --force` |
||
22 | * - `php7.2 '.php-cs-fixer.php' --force` |
||
23 | * - `php7.3 '.php-cs-fixer.php' --force` |
||
24 | * - `php7.4 '.php-cs-fixer.php' --force` |
||
25 | * - `php8.0 '.php-cs-fixer.php' --force` |
||
26 | * |
||
27 | * @see https://cs.symfony.com/ |
||
28 | */ |
||
29 | $rules = [ |
||
30 | /* |
||
31 | * Each line of multi-line DocComments must have an asterisk [PSR-5] |
||
32 | * and must be aligned with the first one. |
||
33 | */ |
||
34 | 'align_multiline_comment' => true, |
||
35 | |||
36 | // Each element of an array must be indented exactly once. |
||
37 | 'array_indentation' => true, |
||
38 | |||
39 | /* |
||
40 | * Converts simple usages of `array_push($x, $y);` to `$x[] = $y;`. |
||
41 | * |
||
42 | * Risky! |
||
43 | * Risky when the function `array_push` is overridden. |
||
44 | */ |
||
45 | 'array_push' => true, |
||
46 | |||
47 | // PHP arrays should be declared using the configured syntax. |
||
48 | 'array_syntax' => [ |
||
49 | 'syntax' => 'short', |
||
50 | ], |
||
51 | |||
52 | // Use the null coalescing assignment operator `??=` where possible. |
||
53 | 'assign_null_coalescing_to_coalesce_equal' => true, |
||
54 | |||
55 | /* |
||
56 | * Converts backtick operators to `shell_exec` calls. |
||
57 | * |
||
58 | * Conversion is done only when it is non risky, so when special |
||
59 | * chars like single-quotes, double-quotes and backticks are not |
||
60 | * used inside the command. |
||
61 | */ |
||
62 | 'backtick_to_shell_exec' => true, |
||
63 | |||
64 | // Binary operators should be surrounded by space as configured. |
||
65 | 'binary_operator_spaces' => true, |
||
66 | |||
67 | // There MUST be one blank line after the namespace declaration. |
||
68 | 'blank_line_after_namespace' => true, |
||
69 | |||
70 | /* |
||
71 | * Ensure there is no code on the same line as the PHP open tag and |
||
72 | * it is followed by a blank line. |
||
73 | */ |
||
74 | 'blank_line_after_opening_tag' => true, |
||
75 | |||
76 | // An empty line feed must precede any configured statement. |
||
77 | 'blank_line_before_statement' => [ |
||
78 | 'statements' => [ |
||
79 | 'declare', |
||
80 | 'return', |
||
81 | 'throw', |
||
82 | 'try', |
||
83 | 'switch', |
||
84 | 'for', |
||
85 | 'if', |
||
86 | 'require', |
||
87 | 'require_once', |
||
88 | 'include', |
||
89 | 'foreach', |
||
90 | 'do', |
||
91 | 'default', |
||
92 | 'case', |
||
93 | 'exit', |
||
94 | 'include_once', |
||
95 | 'while', |
||
96 | ], |
||
97 | ], |
||
98 | |||
99 | /* |
||
100 | * The body of each structure MUST be enclosed by braces. Braces |
||
101 | * should be properly placed. Body of braces should be properly |
||
102 | * indented. |
||
103 | */ |
||
104 | 'braces' => [ |
||
105 | 'allow_single_line_anonymous_class_with_empty_body' => true, |
||
106 | 'allow_single_line_closure' => true, |
||
107 | ], |
||
108 | |||
109 | // A single space or none should be between cast and variable. |
||
110 | 'cast_spaces' => true, |
||
111 | |||
112 | /* |
||
113 | * Class, trait and interface elements must be separated with one or |
||
114 | * none blank line. |
||
115 | */ |
||
116 | 'class_attributes_separation' => true, |
||
117 | |||
118 | /* |
||
119 | * Whitespace around the keywords of a class, trait or interfaces |
||
120 | * definition should be one space. |
||
121 | */ |
||
122 | 'class_definition' => [ |
||
123 | 'single_line' => true, |
||
124 | ], |
||
125 | |||
126 | /* |
||
127 | * When referencing a class it must be written using the correct |
||
128 | * casing. |
||
129 | */ |
||
130 | 'class_reference_name_casing' => true, |
||
131 | |||
132 | // Namespace must not contain spacing, comments or PHPDoc. |
||
133 | 'clean_namespace' => true, |
||
134 | |||
135 | // Using `isset($var) &&` multiple times should be done in one call. |
||
136 | 'combine_consecutive_issets' => true, |
||
137 | |||
138 | // Calling `unset` on multiple items should be done in one call. |
||
139 | 'combine_consecutive_unsets' => true, |
||
140 | |||
141 | /* |
||
142 | * Replace multiple nested calls of `dirname` by only one call with |
||
143 | * second `$level` parameter. Requires PHP >= 7.0. |
||
144 | * |
||
145 | * Risky! |
||
146 | * Risky when the function `dirname` is overridden. |
||
147 | */ |
||
148 | 'combine_nested_dirname' => true, |
||
149 | |||
150 | /* |
||
151 | * Comments with annotation should be docblock when used on |
||
152 | * structural elements. |
||
153 | * |
||
154 | * Risky! |
||
155 | * Risky as new docblocks might mean more, e.g. a Doctrine entity |
||
156 | * might have a new column in database. |
||
157 | */ |
||
158 | 'comment_to_phpdoc' => [ |
||
159 | 'ignored_tags' => [ |
||
160 | 'noinspection', |
||
161 | 'lang', |
||
162 | ], |
||
163 | ], |
||
164 | |||
165 | /* |
||
166 | * Remove extra spaces in a nullable typehint. |
||
167 | * |
||
168 | * Rule is applied only in a PHP 7.1+ environment. |
||
169 | */ |
||
170 | 'compact_nullable_typehint' => true, |
||
171 | |||
172 | // Concatenation should be spaced according configuration. |
||
173 | 'concat_space' => [ |
||
174 | 'spacing' => 'one', |
||
175 | ], |
||
176 | |||
177 | /* |
||
178 | * The PHP constants `true`, `false`, and `null` MUST be written |
||
179 | * using the correct casing. |
||
180 | */ |
||
181 | 'constant_case' => true, |
||
182 | |||
183 | /* |
||
184 | * Control structure continuation keyword must be on the configured |
||
185 | * line. |
||
186 | */ |
||
187 | 'control_structure_continuation_position' => true, |
||
188 | |||
189 | /* |
||
190 | * Class `DateTimeImmutable` should be used instead of `DateTime`. |
||
191 | * |
||
192 | * Risky! |
||
193 | * Risky when the code relies on modifying `DateTime` objects or if |
||
194 | * any of the `date_create*` functions are overridden. |
||
195 | */ |
||
196 | 'date_time_immutable' => true, |
||
197 | |||
198 | /* |
||
199 | * Equal sign in declare statement should be surrounded by spaces or |
||
200 | * not following configuration. |
||
201 | */ |
||
202 | 'declare_equal_normalize' => true, |
||
203 | |||
204 | // There must not be spaces around `declare` statement parentheses. |
||
205 | 'declare_parentheses' => true, |
||
206 | |||
207 | /* |
||
208 | * Force strict types declaration in all files. Requires PHP >= 7.0. |
||
209 | * |
||
210 | * Risky! |
||
211 | * Forcing strict types will stop non strict code from working. |
||
212 | */ |
||
213 | 'declare_strict_types' => true, |
||
214 | |||
215 | /* |
||
216 | * Replaces `dirname(__FILE__)` expression with equivalent `__DIR__` |
||
217 | * constant. |
||
218 | * |
||
219 | * Risky! |
||
220 | * Risky when the function `dirname` is overridden. |
||
221 | */ |
||
222 | 'dir_constant' => true, |
||
223 | |||
224 | /* |
||
225 | * Doctrine annotations must use configured operator for assignment |
||
226 | * in arrays. |
||
227 | */ |
||
228 | 'doctrine_annotation_array_assignment' => [ |
||
229 | 'operator' => ':', |
||
230 | ], |
||
231 | |||
232 | /* |
||
233 | * Doctrine annotations without arguments must use the configured |
||
234 | * syntax. |
||
235 | */ |
||
236 | 'doctrine_annotation_braces' => true, |
||
237 | |||
238 | // Doctrine annotations must be indented with four spaces. |
||
239 | 'doctrine_annotation_indentation' => true, |
||
240 | |||
241 | /* |
||
242 | * Fixes spaces in Doctrine annotations. |
||
243 | * |
||
244 | * There must not be any space around parentheses; commas must be |
||
245 | * preceded by no space and followed by one space; there must be no |
||
246 | * space around named arguments assignment operator; there must be |
||
247 | * one space around array assignment operator. |
||
248 | */ |
||
249 | 'doctrine_annotation_spaces' => true, |
||
250 | |||
251 | /* |
||
252 | * Replaces short-echo `<?=` with long format `<?php echo`/`<?php |
||
253 | * print` syntax, or vice-versa. |
||
254 | */ |
||
255 | 'echo_tag_syntax' => [ |
||
256 | 'format' => 'short', |
||
257 | 'long_function' => 'echo', |
||
258 | 'shorten_simple_statements_only' => true, |
||
259 | ], |
||
260 | |||
261 | /* |
||
262 | * The keyword `elseif` should be used instead of `else if` so that |
||
263 | * all control keywords look like single words. |
||
264 | */ |
||
265 | 'elseif' => true, |
||
266 | |||
267 | // Empty loop-body must be in configured style. |
||
268 | 'empty_loop_body' => true, |
||
269 | |||
270 | // Empty loop-condition must be in configured style. |
||
271 | 'empty_loop_condition' => true, |
||
272 | |||
273 | // PHP code MUST use only UTF-8 without BOM (remove BOM). |
||
274 | 'encoding' => true, |
||
275 | |||
276 | /* |
||
277 | * Replace deprecated `ereg` regular expression functions with |
||
278 | * `preg`. |
||
279 | * |
||
280 | * Risky! |
||
281 | * Risky if the `ereg` function is overridden. |
||
282 | */ |
||
283 | 'ereg_to_preg' => true, |
||
284 | |||
285 | /* |
||
286 | * Error control operator should be added to deprecation notices |
||
287 | * and/or removed from other cases. |
||
288 | * |
||
289 | * Risky! |
||
290 | * Risky because adding/removing `@` might cause changes to code |
||
291 | * behaviour or if `trigger_error` function is overridden. |
||
292 | */ |
||
293 | 'error_suppression' => [ |
||
294 | 'mute_deprecation_error' => true, |
||
295 | 'noise_remaining_usages' => true, |
||
296 | 'noise_remaining_usages_exclude' => [ |
||
297 | 'include', |
||
298 | 'fclose', |
||
299 | 'fopen', |
||
300 | 'gzinflate', |
||
301 | 'iconv', |
||
302 | 'mime_content_type', |
||
303 | 'rename', |
||
304 | 'unlink', |
||
305 | 'fsockopen', |
||
306 | 'chmod', |
||
307 | ], |
||
308 | ], |
||
309 | |||
310 | /* |
||
311 | * Escape implicit backslashes in strings and heredocs to ease the |
||
312 | * understanding of which are special chars interpreted by PHP and |
||
313 | * which not. |
||
314 | * |
||
315 | * In PHP double-quoted strings and heredocs some chars like `n`, |
||
316 | * `$` or `u` have special meanings if preceded by a backslash (and |
||
317 | * some are special only if followed by other special chars), while |
||
318 | * a backslash preceding other chars are interpreted like a plain |
||
319 | * backslash. The precise list of those special chars is hard to |
||
320 | * remember and to identify quickly: this fixer escapes backslashes |
||
321 | * that do not start a special interpretation with the char after |
||
322 | * them. |
||
323 | * It is possible to fix also single-quoted strings: in this case |
||
324 | * there is no special chars apart from single-quote and backslash |
||
325 | * itself, so the fixer simply ensure that all backslashes are |
||
326 | * escaped. Both single and double backslashes are allowed in |
||
327 | * single-quoted strings, so the purpose in this context is mainly |
||
328 | * to have a uniformed way to have them written all over the |
||
329 | * codebase. |
||
330 | */ |
||
331 | 'escape_implicit_backslashes' => true, |
||
332 | |||
333 | /* |
||
334 | * Add curly braces to indirect variables to make them clear to |
||
335 | * understand. Requires PHP >= 7.0. |
||
336 | */ |
||
337 | 'explicit_indirect_variable' => true, |
||
338 | |||
339 | /* |
||
340 | * Converts implicit variables into explicit ones in double-quoted |
||
341 | * strings or heredoc syntax. |
||
342 | * |
||
343 | * The reasoning behind this rule is the following: |
||
344 | * - When there are two valid ways of doing the same thing, using |
||
345 | * both is confusing, there should be a coding standard to follow |
||
346 | * - PHP manual marks `"$var"` syntax as implicit and `"${var}"` |
||
347 | * syntax as explicit: explicit code should always be preferred |
||
348 | * - Explicit syntax allows word concatenation inside strings, e.g. |
||
349 | * `"${var}IsAVar"`, implicit doesn't |
||
350 | * - Explicit syntax is easier to detect for IDE/editors and |
||
351 | * therefore has colors/highlight with higher contrast, which is |
||
352 | * easier to read |
||
353 | * Backtick operator is skipped because it is harder to handle; you |
||
354 | * can use `backtick_to_shell_exec` fixer to normalize backticks to |
||
355 | * strings |
||
356 | */ |
||
357 | 'explicit_string_variable' => true, |
||
358 | |||
359 | /* |
||
360 | * All classes must be final, except abstract ones and Doctrine |
||
361 | * entities. |
||
362 | * |
||
363 | * No exception and no configuration are intentional. Beside |
||
364 | * Doctrine entities and of course abstract classes, there is no |
||
365 | * single reason not to declare all classes final. If you want to |
||
366 | * subclass a class, mark the parent class as abstract and create |
||
367 | * two child classes, one empty if necessary: you'll gain much more |
||
368 | * fine grained type-hinting. If you need to mock a standalone |
||
369 | * class, create an interface, or maybe it's a value-object that |
||
370 | * shouldn't be mocked at all. If you need to extend a standalone |
||
371 | * class, create an interface and use the Composite pattern. If you |
||
372 | * aren't ready yet for serious OOP, go with |
||
373 | * FinalInternalClassFixer, it's fine. |
||
374 | * |
||
375 | * Risky! |
||
376 | * Risky when subclassing non-abstract classes. |
||
377 | */ |
||
378 | 'final_class' => false, |
||
379 | |||
380 | /* |
||
381 | * Internal classes should be `final`. |
||
382 | * |
||
383 | * Risky! |
||
384 | * Changing classes to `final` might cause code execution to break. |
||
385 | */ |
||
386 | 'final_internal_class' => false, |
||
387 | |||
388 | /* |
||
389 | * All `public` methods of `abstract` classes should be `final`. |
||
390 | * |
||
391 | * Enforce API encapsulation in an inheritance architecture. If you |
||
392 | * want to override a method, use the Template method pattern. |
||
393 | * |
||
394 | * Risky! |
||
395 | * Risky when overriding `public` methods of `abstract` classes. |
||
396 | */ |
||
397 | 'final_public_method_for_abstract_class' => false, |
||
398 | |||
399 | /* |
||
400 | * Order the flags in `fopen` calls, `b` and `t` must be last. |
||
401 | * |
||
402 | * Risky! |
||
403 | * Risky when the function `fopen` is overridden. |
||
404 | */ |
||
405 | 'fopen_flag_order' => true, |
||
406 | |||
407 | /* |
||
408 | * The flags in `fopen` calls must omit `t`, and `b` must be omitted |
||
409 | * or included consistently. |
||
410 | * |
||
411 | * Risky! |
||
412 | * Risky when the function `fopen` is overridden. |
||
413 | */ |
||
414 | 'fopen_flags' => [ |
||
415 | 'b_mode' => true, |
||
416 | ], |
||
417 | |||
418 | /* |
||
419 | * PHP code must use the long `<?php` tags or short-echo `<?=` tags |
||
420 | * and not other tag variations. |
||
421 | */ |
||
422 | 'full_opening_tag' => true, |
||
423 | |||
424 | /* |
||
425 | * Transforms imported FQCN parameters and return types in function |
||
426 | * arguments to short version. |
||
427 | */ |
||
428 | 'fully_qualified_strict_types' => true, |
||
429 | |||
430 | // Spaces should be properly placed in a function declaration. |
||
431 | 'function_declaration' => true, |
||
432 | |||
433 | /* |
||
434 | * Replace core functions calls returning constants with the |
||
435 | * constants. |
||
436 | * |
||
437 | * Risky! |
||
438 | * Risky when any of the configured functions to replace are |
||
439 | * overridden. |
||
440 | */ |
||
441 | 'function_to_constant' => [ |
||
442 | 'functions' => [ |
||
443 | 'get_class', |
||
444 | 'php_sapi_name', |
||
445 | 'phpversion', |
||
446 | 'pi', |
||
447 | 'get_called_class', |
||
448 | ], |
||
449 | ], |
||
450 | |||
451 | // Ensure single space between function's argument and its typehint. |
||
452 | 'function_typehint_space' => true, |
||
453 | |||
454 | // Configured annotations should be omitted from PHPDoc. |
||
455 | 'general_phpdoc_annotation_remove' => true, |
||
456 | |||
457 | // Renames PHPDoc tags. |
||
458 | 'general_phpdoc_tag_rename' => [ |
||
459 | 'replacements' => [ |
||
460 | 'inheritDocs' => 'inheritDoc', |
||
461 | ], |
||
462 | ], |
||
463 | |||
464 | /* |
||
465 | * Replace `get_class` calls on object variables with class keyword |
||
466 | * syntax. |
||
467 | * |
||
468 | * Risky! |
||
469 | * Risky if the `get_class` function is overridden. |
||
470 | */ |
||
471 | 'get_class_to_class_keyword' => true, |
||
472 | |||
473 | // Imports or fully qualifies global classes/functions/constants. |
||
474 | 'global_namespace_import' => [ |
||
475 | 'import_constants' => false, |
||
476 | 'import_functions' => false, |
||
477 | 'import_classes' => false, |
||
478 | ], |
||
479 | |||
480 | // There MUST be group use for the same namespaces. |
||
481 | 'group_import' => false, |
||
482 | |||
483 | // Add, replace or remove header comment. |
||
484 | 'header_comment' => [ |
||
485 | 'header' => 'Copyright (c) 2022 Ne-Lexa <[email protected]> |
||
486 | |||
487 | For the full copyright and license information, please view |
||
488 | the LICENSE file that was distributed with this source code. |
||
489 | |||
490 | @see https://github.com/Ne-Lexa/roach-php-bundle', |
||
491 | 'comment_type' => 'comment', |
||
492 | 'location' => 'after_declare_strict', |
||
493 | 'separate' => 'both', |
||
494 | ], |
||
495 | |||
496 | /* |
||
497 | * Heredoc/nowdoc content must be properly indented. Requires PHP >= |
||
498 | * 7.3. |
||
499 | */ |
||
500 | 'heredoc_indentation' => true, |
||
501 | |||
502 | // Convert `heredoc` to `nowdoc` where possible. |
||
503 | 'heredoc_to_nowdoc' => true, |
||
504 | |||
505 | /* |
||
506 | * Function `implode` must be called with 2 arguments in the |
||
507 | * documented order. |
||
508 | * |
||
509 | * Risky! |
||
510 | * Risky when the function `implode` is overridden. |
||
511 | */ |
||
512 | 'implode_call' => true, |
||
513 | |||
514 | /* |
||
515 | * Include/Require and file path should be divided with a single |
||
516 | * space. File path should not be placed under brackets. |
||
517 | */ |
||
518 | 'include' => true, |
||
519 | |||
520 | /* |
||
521 | * Pre- or post-increment and decrement operators should be used if |
||
522 | * possible. |
||
523 | */ |
||
524 | 'increment_style' => false, |
||
525 | |||
526 | // Code MUST use configured indentation type. |
||
527 | 'indentation_type' => true, |
||
528 | |||
529 | // Integer literals must be in correct case. |
||
530 | 'integer_literal_case' => true, |
||
531 | |||
532 | /* |
||
533 | * Replaces `is_null($var)` expression with `null === $var`. |
||
534 | * |
||
535 | * Risky! |
||
536 | * Risky when the function `is_null` is overridden. |
||
537 | */ |
||
538 | 'is_null' => true, |
||
539 | |||
540 | // Lambda must not import variables it doesn't use. |
||
541 | 'lambda_not_used_import' => true, |
||
542 | |||
543 | // All PHP files must use same line ending. |
||
544 | 'line_ending' => true, |
||
545 | |||
546 | // Ensure there is no code on the same line as the PHP open tag. |
||
547 | 'linebreak_after_opening_tag' => true, |
||
548 | |||
549 | /* |
||
550 | * List (`array` destructuring) assignment should be declared using |
||
551 | * the configured syntax. Requires PHP >= 7.1. |
||
552 | */ |
||
553 | 'list_syntax' => [ |
||
554 | 'syntax' => 'short', |
||
555 | ], |
||
556 | |||
557 | /* |
||
558 | * Use `&&` and `||` logical operators instead of `and` and `or`. |
||
559 | * |
||
560 | * Risky! |
||
561 | * Risky, because you must double-check if using and/or with lower |
||
562 | * precedence was intentional. |
||
563 | */ |
||
564 | 'logical_operators' => true, |
||
565 | |||
566 | // Cast should be written in lower case. |
||
567 | 'lowercase_cast' => true, |
||
568 | |||
569 | // PHP keywords MUST be in lower case. |
||
570 | 'lowercase_keywords' => true, |
||
571 | |||
572 | /* |
||
573 | * Class static references `self`, `static` and `parent` MUST be in |
||
574 | * lower case. |
||
575 | */ |
||
576 | 'lowercase_static_reference' => true, |
||
577 | |||
578 | // Magic constants should be referred to using the correct casing. |
||
579 | 'magic_constant_casing' => true, |
||
580 | |||
581 | /* |
||
582 | * Magic method definitions and calls must be using the correct |
||
583 | * casing. |
||
584 | */ |
||
585 | 'magic_method_casing' => true, |
||
586 | |||
587 | /* |
||
588 | * Replace non multibyte-safe functions with corresponding mb |
||
589 | * function. |
||
590 | * |
||
591 | * Risky! |
||
592 | * Risky when any of the functions are overridden, or when relying |
||
593 | * on the string byte size rather than its length in characters. |
||
594 | */ |
||
595 | 'mb_str_functions' => false, |
||
596 | |||
597 | /* |
||
598 | * In method arguments and method call, there MUST NOT be a space |
||
599 | * before each comma and there MUST be one space after each comma. |
||
600 | * Argument lists MAY be split across multiple lines, where each |
||
601 | * subsequent line is indented once. When doing so, the first item |
||
602 | * in the list MUST be on the next line, and there MUST be only one |
||
603 | * argument per line. |
||
604 | */ |
||
605 | 'method_argument_space' => [ |
||
606 | 'on_multiline' => 'ensure_fully_multiline', |
||
607 | ], |
||
608 | |||
609 | /* |
||
610 | * Method chaining MUST be properly indented. Method chaining with |
||
611 | * different levels of indentation is not supported. |
||
612 | */ |
||
613 | 'method_chaining_indentation' => true, |
||
614 | |||
615 | /* |
||
616 | * Replace `strpos()` calls with `str_starts_with()` or |
||
617 | * `str_contains()` if possible. |
||
618 | * |
||
619 | * Risky! |
||
620 | * Risky if `strpos`, `str_starts_with` or `str_contains` functions |
||
621 | * are overridden. |
||
622 | */ |
||
623 | 'modernize_strpos' => true, |
||
624 | |||
625 | /* |
||
626 | * Replaces `intval`, `floatval`, `doubleval`, `strval` and |
||
627 | * `boolval` function calls with according type casting operator. |
||
628 | * |
||
629 | * Risky! |
||
630 | * Risky if any of the functions `intval`, `floatval`, `doubleval`, |
||
631 | * `strval` or `boolval` are overridden. |
||
632 | */ |
||
633 | 'modernize_types_casting' => true, |
||
634 | |||
635 | /* |
||
636 | * DocBlocks must start with two asterisks, multiline comments must |
||
637 | * start with a single asterisk, after the opening slash. Both must |
||
638 | * end with a single asterisk before the closing slash. |
||
639 | */ |
||
640 | 'multiline_comment_opening_closing' => true, |
||
641 | |||
642 | /* |
||
643 | * Forbid multi-line whitespace before the closing semicolon or move |
||
644 | * the semicolon to the new line for chained calls. |
||
645 | */ |
||
646 | 'multiline_whitespace_before_semicolons' => [ |
||
647 | 'strategy' => 'new_line_for_chained_calls', |
||
648 | ], |
||
649 | |||
650 | /* |
||
651 | * Add leading `\` before constant invocation of internal constant |
||
652 | * to speed up resolving. Constant name match is case-sensitive, |
||
653 | * except for `null`, `false` and `true`. |
||
654 | * |
||
655 | * Risky! |
||
656 | * Risky when any of the constants are namespaced or overridden. |
||
657 | */ |
||
658 | 'native_constant_invocation' => true, |
||
659 | |||
660 | /* |
||
661 | * Function defined by PHP should be called using the correct |
||
662 | * casing. |
||
663 | */ |
||
664 | 'native_function_casing' => true, |
||
665 | |||
666 | /* |
||
667 | * Add leading `\` before function invocation to speed up resolving. |
||
668 | * |
||
669 | * Risky! |
||
670 | * Risky when any of the functions are overridden. |
||
671 | */ |
||
672 | 'native_function_invocation' => [ |
||
673 | 'include' => [ |
||
674 | '@compiler_optimized', |
||
675 | ], |
||
676 | 'scope' => 'namespaced', |
||
677 | 'strict' => true, |
||
678 | ], |
||
679 | |||
680 | // Native type hints for functions should use the correct case. |
||
681 | 'native_function_type_declaration_casing' => true, |
||
682 | |||
683 | /* |
||
684 | * All instances created with new keyword must be followed by |
||
685 | * braces. |
||
686 | */ |
||
687 | 'new_with_braces' => true, |
||
688 | |||
689 | /* |
||
690 | * Master functions shall be used instead of aliases. |
||
691 | * |
||
692 | * Risky! |
||
693 | * Risky when any of the alias functions are overridden. |
||
694 | */ |
||
695 | 'no_alias_functions' => [ |
||
696 | 'sets' => [ |
||
697 | '@all', |
||
698 | ], |
||
699 | ], |
||
700 | |||
701 | // Master language constructs shall be used instead of aliases. |
||
702 | 'no_alias_language_construct_call' => true, |
||
703 | |||
704 | // Replace control structure alternative syntax to use braces. |
||
705 | 'no_alternative_syntax' => true, |
||
706 | |||
707 | // There should not be a binary flag before strings. |
||
708 | 'no_binary_string' => true, |
||
709 | |||
710 | // There should be no empty lines after class opening brace. |
||
711 | 'no_blank_lines_after_class_opening' => true, |
||
712 | |||
713 | /* |
||
714 | * There should not be blank lines between docblock and the |
||
715 | * documented element. |
||
716 | */ |
||
717 | 'no_blank_lines_after_phpdoc' => true, |
||
718 | |||
719 | // There should be no blank lines before a namespace declaration. |
||
720 | 'no_blank_lines_before_namespace' => false, |
||
721 | |||
722 | /* |
||
723 | * There must be a comment when fall-through is intentional in a |
||
724 | * non-empty case body. |
||
725 | * |
||
726 | * Adds a "no break" comment before fall-through cases, and removes |
||
727 | * it if there is no fall-through. |
||
728 | */ |
||
729 | 'no_break_comment' => [ |
||
730 | 'comment_text' => 'no break', |
||
731 | ], |
||
732 | |||
733 | /* |
||
734 | * The closing `?>` tag MUST be omitted from files containing only |
||
735 | * PHP. |
||
736 | */ |
||
737 | 'no_closing_tag' => true, |
||
738 | |||
739 | // There should not be any empty comments. |
||
740 | 'no_empty_comment' => true, |
||
741 | |||
742 | // There should not be empty PHPDoc blocks. |
||
743 | 'no_empty_phpdoc' => true, |
||
744 | |||
745 | // Remove useless (semicolon) statements. |
||
746 | 'no_empty_statement' => true, |
||
747 | |||
748 | /* |
||
749 | * Removes extra blank lines and/or blank lines following |
||
750 | * configuration. |
||
751 | */ |
||
752 | 'no_extra_blank_lines' => [ |
||
753 | 'tokens' => [ |
||
754 | 'case', |
||
755 | 'continue', |
||
756 | 'curly_brace_block', |
||
757 | 'default', |
||
758 | 'extra', |
||
759 | 'parenthesis_brace_block', |
||
760 | 'square_brace_block', |
||
761 | 'switch', |
||
762 | 'throw', |
||
763 | 'use', |
||
764 | ], |
||
765 | ], |
||
766 | |||
767 | /* |
||
768 | * Replace accidental usage of homoglyphs (non ascii characters) in |
||
769 | * names. |
||
770 | * |
||
771 | * Risky! |
||
772 | * Renames classes and cannot rename the files. You might have |
||
773 | * string references to renamed code (`$$name`). |
||
774 | */ |
||
775 | 'no_homoglyph_names' => true, |
||
776 | |||
777 | // Remove leading slashes in `use` clauses. |
||
778 | 'no_leading_import_slash' => true, |
||
779 | |||
780 | /* |
||
781 | * The namespace declaration line shouldn't contain leading |
||
782 | * whitespace. |
||
783 | */ |
||
784 | 'no_leading_namespace_whitespace' => true, |
||
785 | |||
786 | // Either language construct `print` or `echo` should be used. |
||
787 | 'no_mixed_echo_print' => true, |
||
788 | |||
789 | // Operator `=>` should not be surrounded by multi-line whitespaces. |
||
790 | 'no_multiline_whitespace_around_double_arrow' => true, |
||
791 | |||
792 | /* |
||
793 | * Properties MUST not be explicitly initialized with `null` except |
||
794 | * when they have a type declaration (PHP 7.4). |
||
795 | */ |
||
796 | 'no_null_property_initialization' => true, |
||
797 | |||
798 | /* |
||
799 | * Convert PHP4-style constructors to `__construct`. |
||
800 | * |
||
801 | * Risky! |
||
802 | * Risky when old style constructor being fixed is overridden or |
||
803 | * overrides parent one. |
||
804 | */ |
||
805 | 'no_php4_constructor' => true, |
||
806 | |||
807 | /* |
||
808 | * Short cast `bool` using double exclamation mark should not be |
||
809 | * used. |
||
810 | */ |
||
811 | 'no_short_bool_cast' => true, |
||
812 | |||
813 | // Single-line whitespace before closing semicolon are prohibited. |
||
814 | 'no_singleline_whitespace_before_semicolons' => true, |
||
815 | |||
816 | /* |
||
817 | * There must be no space around double colons (also called Scope |
||
818 | * Resolution Operator or Paamayim Nekudotayim). |
||
819 | */ |
||
820 | 'no_space_around_double_colon' => true, |
||
821 | |||
822 | /* |
||
823 | * When making a method or function call, there MUST NOT be a space |
||
824 | * between the method or function name and the opening parenthesis. |
||
825 | */ |
||
826 | 'no_spaces_after_function_name' => true, |
||
827 | |||
828 | // There MUST NOT be spaces around offset braces. |
||
829 | 'no_spaces_around_offset' => true, |
||
830 | |||
831 | /* |
||
832 | * There MUST NOT be a space after the opening parenthesis. There |
||
833 | * MUST NOT be a space before the closing parenthesis. |
||
834 | */ |
||
835 | 'no_spaces_inside_parenthesis' => true, |
||
836 | |||
837 | // Replaces superfluous `elseif` with `if`. |
||
838 | 'no_superfluous_elseif' => true, |
||
839 | |||
840 | /* |
||
841 | * Removes `@param`, `@return` and `@var` tags that don't provide |
||
842 | * any useful information. |
||
843 | */ |
||
844 | 'no_superfluous_phpdoc_tags' => [ |
||
845 | 'allow_mixed' => true, |
||
846 | 'remove_inheritdoc' => true, |
||
847 | 'allow_unused_params' => false, |
||
848 | ], |
||
849 | |||
850 | // Remove trailing commas in list function calls. |
||
851 | 'no_trailing_comma_in_list_call' => true, |
||
852 | |||
853 | // PHP single-line arrays should not have trailing comma. |
||
854 | 'no_trailing_comma_in_singleline_array' => true, |
||
855 | |||
856 | // Remove trailing whitespace at the end of non-blank lines. |
||
857 | 'no_trailing_whitespace' => true, |
||
858 | |||
859 | // There MUST be no trailing spaces inside comment or PHPDoc. |
||
860 | 'no_trailing_whitespace_in_comment' => true, |
||
861 | |||
862 | /* |
||
863 | * There must be no trailing whitespace in strings. |
||
864 | * |
||
865 | * Risky! |
||
866 | * Changing the whitespaces in strings might affect string |
||
867 | * comparisons and outputs. |
||
868 | */ |
||
869 | 'no_trailing_whitespace_in_string' => false, |
||
870 | |||
871 | // Removes unneeded parentheses around control statements. |
||
872 | 'no_unneeded_control_parentheses' => [ |
||
873 | 'statements' => [ |
||
874 | 'break', |
||
875 | 'clone', |
||
876 | 'continue', |
||
877 | 'echo_print', |
||
878 | 'return', |
||
879 | 'switch_case', |
||
880 | 'yield', |
||
881 | 'yield_from', |
||
882 | ], |
||
883 | ], |
||
884 | |||
885 | /* |
||
886 | * Removes unneeded curly braces that are superfluous and aren't |
||
887 | * part of a control structure's body. |
||
888 | */ |
||
889 | 'no_unneeded_curly_braces' => [ |
||
890 | 'namespaces' => true, |
||
891 | ], |
||
892 | |||
893 | /* |
||
894 | * A `final` class must not have `final` methods and `private` |
||
895 | * methods must not be `final`. |
||
896 | * |
||
897 | * Risky! |
||
898 | * Risky when child class overrides a `private` method. |
||
899 | */ |
||
900 | 'no_unneeded_final_method' => true, |
||
901 | |||
902 | // Imports should not be aliased as the same name. |
||
903 | 'no_unneeded_import_alias' => true, |
||
904 | |||
905 | /* |
||
906 | * In function arguments there must not be arguments with default |
||
907 | * values before non-default ones. |
||
908 | * |
||
909 | * Risky! |
||
910 | * Modifies the signature of functions; therefore risky when using |
||
911 | * systems (such as some Symfony components) that rely on those (for |
||
912 | * example through reflection). |
||
913 | */ |
||
914 | 'no_unreachable_default_argument_value' => true, |
||
915 | |||
916 | // Variables must be set `null` instead of using `(unset)` casting. |
||
917 | 'no_unset_cast' => true, |
||
918 | |||
919 | /* |
||
920 | * Properties should be set to `null` instead of using `unset`. |
||
921 | * |
||
922 | * Risky! |
||
923 | * Risky when relying on attributes to be removed using `unset` |
||
924 | * rather than be set to `null`. Changing variables to `null` |
||
925 | * instead of unsetting means these still show up when looping over |
||
926 | * class variables and reference properties remain unbroken. With |
||
927 | * PHP 7.4, this rule might introduce `null` assignments to |
||
928 | * properties whose type declaration does not allow it. |
||
929 | */ |
||
930 | 'no_unset_on_property' => true, |
||
931 | |||
932 | // Unused `use` statements must be removed. |
||
933 | 'no_unused_imports' => true, |
||
934 | |||
935 | // There should not be useless `else` cases. |
||
936 | 'no_useless_else' => true, |
||
937 | |||
938 | /* |
||
939 | * There should not be an empty `return` statement at the end of a |
||
940 | * function. |
||
941 | */ |
||
942 | 'no_useless_return' => true, |
||
943 | |||
944 | /* |
||
945 | * There must be no `sprintf` calls with only the first argument. |
||
946 | * |
||
947 | * Risky! |
||
948 | * Risky when if the `sprintf` function is overridden. |
||
949 | */ |
||
950 | 'no_useless_sprintf' => true, |
||
951 | |||
952 | /* |
||
953 | * In array declaration, there MUST NOT be a whitespace before each |
||
954 | * comma. |
||
955 | */ |
||
956 | 'no_whitespace_before_comma_in_array' => true, |
||
957 | |||
958 | // Remove trailing whitespace at the end of blank lines. |
||
959 | 'no_whitespace_in_blank_line' => true, |
||
960 | |||
961 | /* |
||
962 | * Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and |
||
963 | * other invisible unicode symbols. |
||
964 | * |
||
965 | * Risky! |
||
966 | * Risky when strings contain intended invisible characters. |
||
967 | */ |
||
968 | 'non_printable_character' => true, |
||
969 | |||
970 | // Array index should always be written by using square braces. |
||
971 | 'normalize_index_brace' => true, |
||
972 | |||
973 | /* |
||
974 | * Logical NOT operators (`!`) should have leading and trailing |
||
975 | * whitespaces. |
||
976 | */ |
||
977 | 'not_operator_with_space' => false, |
||
978 | |||
979 | // Logical NOT operators (`!`) should have one trailing whitespace. |
||
980 | 'not_operator_with_successor_space' => false, |
||
981 | |||
982 | /* |
||
983 | * Adds or removes `?` before type declarations for parameters with |
||
984 | * a default `null` value. |
||
985 | * |
||
986 | * Rule is applied only in a PHP 7.1+ environment. |
||
987 | */ |
||
988 | 'nullable_type_declaration_for_default_null_value' => true, |
||
989 | |||
990 | /* |
||
991 | * There should not be space before or after object operators `->` |
||
992 | * and `?->`. |
||
993 | */ |
||
994 | 'object_operator_without_whitespace' => true, |
||
995 | |||
996 | // Literal octal must be in `0o` notation. |
||
997 | 'octal_notation' => true, |
||
998 | |||
999 | /* |
||
1000 | * Operators - when multiline - must always be at the beginning or |
||
1001 | * at the end of the line. |
||
1002 | */ |
||
1003 | 'operator_linebreak' => true, |
||
1004 | |||
1005 | // Orders the elements of classes/interfaces/traits. |
||
1006 | 'ordered_class_elements' => [ |
||
1007 | 'order' => [ |
||
1008 | 'use_trait', |
||
1009 | 'constant_public', |
||
1010 | 'constant_protected', |
||
1011 | 'constant_private', |
||
1012 | 'property_public', |
||
1013 | 'property_protected', |
||
1014 | 'property_private', |
||
1015 | 'construct', |
||
1016 | 'destruct', |
||
1017 | 'magic', |
||
1018 | 'phpunit', |
||
1019 | ], |
||
1020 | ], |
||
1021 | |||
1022 | // Ordering `use` statements. |
||
1023 | 'ordered_imports' => [ |
||
1024 | 'sort_algorithm' => 'alpha', |
||
1025 | 'imports_order' => [ |
||
1026 | 'class', |
||
1027 | 'const', |
||
1028 | 'function', |
||
1029 | ], |
||
1030 | ], |
||
1031 | |||
1032 | /* |
||
1033 | * Orders the interfaces in an `implements` or `interface extends` |
||
1034 | * clause. |
||
1035 | * |
||
1036 | * Risky! |
||
1037 | * Risky for `implements` when specifying both an interface and its |
||
1038 | * parent interface, because PHP doesn't break on `parent, child` |
||
1039 | * but does on `child, parent`. |
||
1040 | */ |
||
1041 | 'ordered_interfaces' => false, |
||
1042 | |||
1043 | /* |
||
1044 | * Trait `use` statements must be sorted alphabetically. |
||
1045 | * |
||
1046 | * Risky! |
||
1047 | * Risky when depending on order of the imports. |
||
1048 | */ |
||
1049 | 'ordered_traits' => true, |
||
1050 | |||
1051 | /* |
||
1052 | * PHPUnit assertion method calls like `->assertSame(true, $foo)` |
||
1053 | * should be written with dedicated method like |
||
1054 | * `->assertTrue($foo)`. |
||
1055 | * |
||
1056 | * Risky! |
||
1057 | * Fixer could be risky if one is overriding PHPUnit's native |
||
1058 | * methods. |
||
1059 | */ |
||
1060 | 'php_unit_construct' => true, |
||
1061 | |||
1062 | /* |
||
1063 | * PHPUnit assertions like `assertInternalType`, `assertFileExists`, |
||
1064 | * should be used over `assertTrue`. |
||
1065 | * |
||
1066 | * Risky! |
||
1067 | * Fixer could be risky if one is overriding PHPUnit's native |
||
1068 | * methods. |
||
1069 | */ |
||
1070 | 'php_unit_dedicate_assert' => [ |
||
1071 | 'target' => '5.6', |
||
1072 | ], |
||
1073 | |||
1074 | /* |
||
1075 | * PHPUnit assertions like `assertIsArray` should be used over |
||
1076 | * `assertInternalType`. |
||
1077 | * |
||
1078 | * Risky! |
||
1079 | * Risky when PHPUnit methods are overridden or when project has |
||
1080 | * PHPUnit incompatibilities. |
||
1081 | */ |
||
1082 | 'php_unit_dedicate_assert_internal_type' => true, |
||
1083 | |||
1084 | /* |
||
1085 | * Usages of `->setExpectedException*` methods MUST be replaced by |
||
1086 | * `->expectException*` methods. |
||
1087 | * |
||
1088 | * Risky! |
||
1089 | * Risky when PHPUnit classes are overridden or not accessible, or |
||
1090 | * when project has PHPUnit incompatibilities. |
||
1091 | */ |
||
1092 | 'php_unit_expectation' => true, |
||
1093 | |||
1094 | // PHPUnit annotations should be a FQCNs including a root namespace. |
||
1095 | 'php_unit_fqcn_annotation' => true, |
||
1096 | |||
1097 | // All PHPUnit test classes should be marked as internal. |
||
1098 | 'php_unit_internal_class' => true, |
||
1099 | |||
1100 | /* |
||
1101 | * Enforce camel (or snake) case for PHPUnit test methods, following |
||
1102 | * configuration. |
||
1103 | */ |
||
1104 | 'php_unit_method_casing' => true, |
||
1105 | |||
1106 | /* |
||
1107 | * Usages of `->getMock` and |
||
1108 | * `->getMockWithoutInvokingTheOriginalConstructor` methods MUST be |
||
1109 | * replaced by `->createMock` or `->createPartialMock` methods. |
||
1110 | * |
||
1111 | * Risky! |
||
1112 | * Risky when PHPUnit classes are overridden or not accessible, or |
||
1113 | * when project has PHPUnit incompatibilities. |
||
1114 | */ |
||
1115 | 'php_unit_mock' => true, |
||
1116 | |||
1117 | /* |
||
1118 | * Usage of PHPUnit's mock e.g. `->will($this->returnValue(..))` |
||
1119 | * must be replaced by its shorter equivalent such as |
||
1120 | * `->willReturn(...)`. |
||
1121 | * |
||
1122 | * Risky! |
||
1123 | * Risky when PHPUnit classes are overridden or not accessible, or |
||
1124 | * when project has PHPUnit incompatibilities. |
||
1125 | */ |
||
1126 | 'php_unit_mock_short_will_return' => true, |
||
1127 | |||
1128 | /* |
||
1129 | * PHPUnit classes MUST be used in namespaced version, e.g. |
||
1130 | * `\PHPUnit\Framework\TestCase` instead of |
||
1131 | * `\PHPUnit_Framework_TestCase`. |
||
1132 | * |
||
1133 | * PHPUnit v6 has finally fully switched to namespaces. |
||
1134 | * You could start preparing the upgrade by switching from |
||
1135 | * non-namespaced TestCase to namespaced one. |
||
1136 | * Forward compatibility layer (`\PHPUnit\Framework\TestCase` class) |
||
1137 | * was backported to PHPUnit v4.8.35 and PHPUnit v5.4.0. |
||
1138 | * Extended forward compatibility layer (`PHPUnit\Framework\Assert`, |
||
1139 | * `PHPUnit\Framework\BaseTestListener`, |
||
1140 | * `PHPUnit\Framework\TestListener` classes) was introduced in |
||
1141 | * v5.7.0. |
||
1142 | * |
||
1143 | * Risky! |
||
1144 | * Risky when PHPUnit classes are overridden or not accessible, or |
||
1145 | * when project has PHPUnit incompatibilities. |
||
1146 | */ |
||
1147 | 'php_unit_namespaced' => true, |
||
1148 | |||
1149 | /* |
||
1150 | * Usages of `@expectedException*` annotations MUST be replaced by |
||
1151 | * `->setExpectedException*` methods. |
||
1152 | * |
||
1153 | * Risky! |
||
1154 | * Risky when PHPUnit classes are overridden or not accessible, or |
||
1155 | * when project has PHPUnit incompatibilities. |
||
1156 | */ |
||
1157 | 'php_unit_no_expectation_annotation' => true, |
||
1158 | |||
1159 | /* |
||
1160 | * Changes the visibility of the `setUp()` and `tearDown()` |
||
1161 | * functions of PHPUnit to `protected`, to match the PHPUnit |
||
1162 | * TestCase. |
||
1163 | * |
||
1164 | * Risky! |
||
1165 | * This fixer may change functions named `setUp()` or `tearDown()` |
||
1166 | * outside of PHPUnit tests, when a class is wrongly seen as a |
||
1167 | * PHPUnit test. |
||
1168 | */ |
||
1169 | 'php_unit_set_up_tear_down_visibility' => true, |
||
1170 | |||
1171 | /* |
||
1172 | * All PHPUnit test cases should have `@small`, `@medium` or |
||
1173 | * `@large` annotation to enable run time limits. |
||
1174 | * |
||
1175 | * The special groups [small, medium, large] provides a way to |
||
1176 | * identify tests that are taking long to be executed. |
||
1177 | */ |
||
1178 | 'php_unit_size_class' => true, |
||
1179 | |||
1180 | /* |
||
1181 | * PHPUnit methods like `assertSame` should be used instead of |
||
1182 | * `assertEquals`. |
||
1183 | * |
||
1184 | * Risky! |
||
1185 | * Risky when any of the functions are overridden or when testing |
||
1186 | * object equality. |
||
1187 | */ |
||
1188 | 'php_unit_strict' => false, |
||
1189 | |||
1190 | /* |
||
1191 | * Adds or removes @test annotations from tests, following |
||
1192 | * configuration. |
||
1193 | * |
||
1194 | * Risky! |
||
1195 | * This fixer may change the name of your tests, and could cause |
||
1196 | * incompatibility with abstract classes or interfaces. |
||
1197 | */ |
||
1198 | 'php_unit_test_annotation' => true, |
||
1199 | |||
1200 | /* |
||
1201 | * Calls to `PHPUnit\Framework\TestCase` static methods must all be |
||
1202 | * of the same type, either `$this->`, `self::` or `static::`. |
||
1203 | * |
||
1204 | * Risky! |
||
1205 | * Risky when PHPUnit methods are overridden or not accessible, or |
||
1206 | * when project has PHPUnit incompatibilities. |
||
1207 | */ |
||
1208 | 'php_unit_test_case_static_method_calls' => true, |
||
1209 | |||
1210 | /* |
||
1211 | * Adds a default `@coversNothing` annotation to PHPUnit test |
||
1212 | * classes that have no `@covers*` annotation. |
||
1213 | */ |
||
1214 | 'php_unit_test_class_requires_covers' => false, |
||
1215 | |||
1216 | // PHPDoc should contain `@param` for all params. |
||
1217 | 'phpdoc_add_missing_param_annotation' => true, |
||
1218 | |||
1219 | /* |
||
1220 | * All items of the given phpdoc tags must be either left-aligned or |
||
1221 | * (by default) aligned vertically. |
||
1222 | */ |
||
1223 | 'phpdoc_align' => [ |
||
1224 | 'tags' => [ |
||
1225 | 'return', |
||
1226 | 'throws', |
||
1227 | 'type', |
||
1228 | 'var', |
||
1229 | 'property', |
||
1230 | 'method', |
||
1231 | 'param', |
||
1232 | ], |
||
1233 | 'align' => 'vertical', |
||
1234 | ], |
||
1235 | |||
1236 | // PHPDoc annotation descriptions should not be a sentence. |
||
1237 | 'phpdoc_annotation_without_dot' => true, |
||
1238 | |||
1239 | /* |
||
1240 | * Docblocks should have the same indentation as the documented |
||
1241 | * subject. |
||
1242 | */ |
||
1243 | 'phpdoc_indent' => true, |
||
1244 | |||
1245 | // Fixes PHPDoc inline tags. |
||
1246 | 'phpdoc_inline_tag_normalizer' => true, |
||
1247 | |||
1248 | /* |
||
1249 | * Changes doc blocks from single to multi line, or reversed. Works |
||
1250 | * for class constants, properties and methods only. |
||
1251 | */ |
||
1252 | 'phpdoc_line_span' => [ |
||
1253 | 'const' => 'single', |
||
1254 | 'property' => 'single', |
||
1255 | 'method' => 'multi', |
||
1256 | ], |
||
1257 | |||
1258 | // `@access` annotations should be omitted from PHPDoc. |
||
1259 | 'phpdoc_no_access' => true, |
||
1260 | |||
1261 | // No alias PHPDoc tags should be used. |
||
1262 | 'phpdoc_no_alias_tag' => true, |
||
1263 | |||
1264 | /* |
||
1265 | * `@return void` and `@return null` annotations should be omitted |
||
1266 | * from PHPDoc. |
||
1267 | */ |
||
1268 | 'phpdoc_no_empty_return' => true, |
||
1269 | |||
1270 | /* |
||
1271 | * `@package` and `@subpackage` annotations should be omitted from |
||
1272 | * PHPDoc. |
||
1273 | */ |
||
1274 | 'phpdoc_no_package' => true, |
||
1275 | |||
1276 | // Classy that does not inherit must not have `@inheritdoc` tags. |
||
1277 | 'phpdoc_no_useless_inheritdoc' => true, |
||
1278 | |||
1279 | /* |
||
1280 | * Annotations in PHPDoc should be ordered so that `@param` |
||
1281 | * annotations come first, then `@throws` annotations, then |
||
1282 | * `@return` annotations. |
||
1283 | */ |
||
1284 | 'phpdoc_order' => true, |
||
1285 | |||
1286 | // Order phpdoc tags by value. |
||
1287 | 'phpdoc_order_by_value' => [ |
||
1288 | 'annotations' => [ |
||
1289 | 'covers', |
||
1290 | 'method', |
||
1291 | 'property', |
||
1292 | 'property-write', |
||
1293 | 'property-read', |
||
1294 | ], |
||
1295 | ], |
||
1296 | |||
1297 | /* |
||
1298 | * The type of `@return` annotations of methods returning a |
||
1299 | * reference to itself must the configured one. |
||
1300 | */ |
||
1301 | 'phpdoc_return_self_reference' => true, |
||
1302 | |||
1303 | /* |
||
1304 | * Scalar types should always be written in the same form. `int` not |
||
1305 | * `integer`, `bool` not `boolean`, `float` not `real` or `double`. |
||
1306 | */ |
||
1307 | 'phpdoc_scalar' => true, |
||
1308 | |||
1309 | /* |
||
1310 | * Annotations in PHPDoc should be grouped together so that |
||
1311 | * annotations of the same type immediately follow each other, and |
||
1312 | * annotations of a different type are separated by a single blank |
||
1313 | * line. |
||
1314 | */ |
||
1315 | 'phpdoc_separation' => true, |
||
1316 | |||
1317 | // Single line `@var` PHPDoc should have proper spacing. |
||
1318 | 'phpdoc_single_line_var_spacing' => true, |
||
1319 | |||
1320 | /* |
||
1321 | * PHPDoc summary should end in either a full stop, exclamation |
||
1322 | * mark, or question mark. |
||
1323 | */ |
||
1324 | 'phpdoc_summary' => true, |
||
1325 | |||
1326 | // Fixes casing of PHPDoc tags. |
||
1327 | 'phpdoc_tag_casing' => true, |
||
1328 | |||
1329 | // Forces PHPDoc tags to be either regular annotations or inline. |
||
1330 | 'phpdoc_tag_type' => [ |
||
1331 | 'tags' => [ |
||
1332 | 'inheritDoc' => 'inline', |
||
1333 | ], |
||
1334 | ], |
||
1335 | |||
1336 | // Docblocks should only be used on structural elements. |
||
1337 | 'phpdoc_to_comment' => [ |
||
1338 | 'ignored_tags' => [ |
||
1339 | 'noinspection', |
||
1340 | ], |
||
1341 | ], |
||
1342 | |||
1343 | /* |
||
1344 | * EXPERIMENTAL: Takes `@param` annotations of non-mixed types and |
||
1345 | * adjusts accordingly the function signature. Requires PHP >= 7.0. |
||
1346 | * |
||
1347 | * Risky! |
||
1348 | * This rule is EXPERIMENTAL and [1] is not covered with backward |
||
1349 | * compatibility promise. [2] `@param` annotation is mandatory for |
||
1350 | * the fixer to make changes, signatures of methods without it (no |
||
1351 | * docblock, inheritdocs) will not be fixed. [3] Manual actions are |
||
1352 | * required if inherited signatures are not properly documented. |
||
1353 | */ |
||
1354 | 'phpdoc_to_param_type' => false, |
||
1355 | |||
1356 | /* |
||
1357 | * EXPERIMENTAL: Takes `@var` annotation of non-mixed types and |
||
1358 | * adjusts accordingly the property signature. Requires PHP >= 7.4. |
||
1359 | * |
||
1360 | * Risky! |
||
1361 | * This rule is EXPERIMENTAL and [1] is not covered with backward |
||
1362 | * compatibility promise. [2] `@var` annotation is mandatory for the |
||
1363 | * fixer to make changes, signatures of properties without it (no |
||
1364 | * docblock) will not be fixed. [3] Manual actions might be required |
||
1365 | * for newly typed properties that are read before initialization. |
||
1366 | */ |
||
1367 | 'phpdoc_to_property_type' => [ |
||
1368 | 'scalar_types' => true, |
||
1369 | ], |
||
1370 | |||
1371 | /* |
||
1372 | * EXPERIMENTAL: Takes `@return` annotation of non-mixed types and |
||
1373 | * adjusts accordingly the function signature. Requires PHP >= 7.0. |
||
1374 | * |
||
1375 | * Risky! |
||
1376 | * This rule is EXPERIMENTAL and [1] is not covered with backward |
||
1377 | * compatibility promise. [2] `@return` annotation is mandatory for |
||
1378 | * the fixer to make changes, signatures of methods without it (no |
||
1379 | * docblock, inheritdocs) will not be fixed. [3] Manual actions are |
||
1380 | * required if inherited signatures are not properly documented. |
||
1381 | */ |
||
1382 | 'phpdoc_to_return_type' => true, |
||
1383 | |||
1384 | /* |
||
1385 | * PHPDoc should start and end with content, excluding the very |
||
1386 | * first and last line of the docblocks. |
||
1387 | */ |
||
1388 | 'phpdoc_trim' => true, |
||
1389 | |||
1390 | /* |
||
1391 | * Removes extra blank lines after summary and after description in |
||
1392 | * PHPDoc. |
||
1393 | */ |
||
1394 | 'phpdoc_trim_consecutive_blank_line_separation' => true, |
||
1395 | |||
1396 | // The correct case must be used for standard PHP types in PHPDoc. |
||
1397 | 'phpdoc_types' => true, |
||
1398 | |||
1399 | // Sorts PHPDoc types. |
||
1400 | 'phpdoc_types_order' => [ |
||
1401 | 'sort_algorithm' => 'none', |
||
1402 | 'null_adjustment' => 'always_last', |
||
1403 | ], |
||
1404 | |||
1405 | /* |
||
1406 | * `@var` and `@type` annotations must have type and name in the |
||
1407 | * correct order. |
||
1408 | */ |
||
1409 | 'phpdoc_var_annotation_correct_order' => true, |
||
1410 | |||
1411 | /* |
||
1412 | * `@var` and `@type` annotations of classy properties should not |
||
1413 | * contain the name. |
||
1414 | */ |
||
1415 | 'phpdoc_var_without_name' => true, |
||
1416 | |||
1417 | /* |
||
1418 | * Converts `pow` to the `**` operator. |
||
1419 | * |
||
1420 | * Risky! |
||
1421 | * Risky when the function `pow` is overridden. |
||
1422 | */ |
||
1423 | 'pow_to_exponentiation' => true, |
||
1424 | |||
1425 | /* |
||
1426 | * Converts `protected` variables and methods to `private` where |
||
1427 | * possible. |
||
1428 | */ |
||
1429 | 'protected_to_private' => true, |
||
1430 | |||
1431 | /* |
||
1432 | * Classes must be in a path that matches their namespace, be at |
||
1433 | * least one namespace deep and the class name should match the file |
||
1434 | * name. |
||
1435 | * |
||
1436 | * Risky! |
||
1437 | * This fixer may change your class name, which will break the code |
||
1438 | * that depends on the old name. |
||
1439 | */ |
||
1440 | 'psr_autoloading' => false, |
||
1441 | |||
1442 | /* |
||
1443 | * Replaces `rand`, `srand`, `getrandmax` functions calls with their |
||
1444 | * `mt_*` analogs or `random_int`. |
||
1445 | * |
||
1446 | * Risky! |
||
1447 | * Risky when the configured functions are overridden. Or when |
||
1448 | * relying on the seed based generating of the numbers. |
||
1449 | */ |
||
1450 | 'random_api_migration' => [ |
||
1451 | 'replacements' => [ |
||
1452 | 'mt_rand' => 'random_int', |
||
1453 | 'rand' => 'random_int', |
||
1454 | ], |
||
1455 | ], |
||
1456 | |||
1457 | /* |
||
1458 | * Callables must be called without using `call_user_func*` when |
||
1459 | * possible. |
||
1460 | * |
||
1461 | * Risky! |
||
1462 | * Risky when the `call_user_func` or `call_user_func_array` |
||
1463 | * function is overridden or when are used in constructions that |
||
1464 | * should be avoided, like `call_user_func_array('foo', ['bar' => |
||
1465 | * 'baz'])` or `call_user_func($foo, $foo = 'bar')`. |
||
1466 | */ |
||
1467 | 'regular_callable_call' => true, |
||
1468 | |||
1469 | /* |
||
1470 | * Local, dynamic and directly referenced variables should not be |
||
1471 | * assigned and directly returned by a function or method. |
||
1472 | */ |
||
1473 | 'return_assignment' => true, |
||
1474 | |||
1475 | /* |
||
1476 | * There should be one or no space before colon, and one space after |
||
1477 | * it in return type declarations, according to configuration. |
||
1478 | * |
||
1479 | * Rule is applied only in a PHP 7+ environment. |
||
1480 | */ |
||
1481 | 'return_type_declaration' => true, |
||
1482 | |||
1483 | /* |
||
1484 | * Inside class or interface element `self` should be preferred to |
||
1485 | * the class name itself. |
||
1486 | * |
||
1487 | * Risky! |
||
1488 | * Risky when using dynamic calls like get_called_class() or late |
||
1489 | * static binding. |
||
1490 | */ |
||
1491 | 'self_accessor' => true, |
||
1492 | |||
1493 | /* |
||
1494 | * Inside a `final` class or anonymous class `self` should be |
||
1495 | * preferred to `static`. |
||
1496 | */ |
||
1497 | 'self_static_accessor' => true, |
||
1498 | |||
1499 | // Instructions must be terminated with a semicolon. |
||
1500 | 'semicolon_after_instruction' => true, |
||
1501 | |||
1502 | /* |
||
1503 | * Cast shall be used, not `settype`. |
||
1504 | * |
||
1505 | * Risky! |
||
1506 | * Risky when the `settype` function is overridden or when used as |
||
1507 | * the 2nd or 3rd expression in a `for` loop . |
||
1508 | */ |
||
1509 | 'set_type_to_cast' => true, |
||
1510 | |||
1511 | /* |
||
1512 | * Cast `(boolean)` and `(integer)` should be written as `(bool)` |
||
1513 | * and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as |
||
1514 | * `(string)`. |
||
1515 | */ |
||
1516 | 'short_scalar_cast' => true, |
||
1517 | |||
1518 | /* |
||
1519 | * Converts explicit variables in double-quoted strings and heredoc |
||
1520 | * syntax from simple to complex format (`${` to `{$`). |
||
1521 | * |
||
1522 | * Doesn't touch implicit variables. Works together nicely with |
||
1523 | * `explicit_string_variable`. |
||
1524 | */ |
||
1525 | 'simple_to_complex_string_variable' => true, |
||
1526 | |||
1527 | /* |
||
1528 | * Simplify `if` control structures that return the boolean result |
||
1529 | * of their condition. |
||
1530 | */ |
||
1531 | 'simplified_if_return' => true, |
||
1532 | |||
1533 | /* |
||
1534 | * A return statement wishing to return `void` should not return |
||
1535 | * `null`. |
||
1536 | */ |
||
1537 | 'simplified_null_return' => false, |
||
1538 | |||
1539 | /* |
||
1540 | * A PHP file without end tag must always end with a single empty |
||
1541 | * line feed. |
||
1542 | */ |
||
1543 | 'single_blank_line_at_eof' => true, |
||
1544 | |||
1545 | /* |
||
1546 | * There should be exactly one blank line before a namespace |
||
1547 | * declaration. |
||
1548 | */ |
||
1549 | 'single_blank_line_before_namespace' => true, |
||
1550 | |||
1551 | /* |
||
1552 | * There MUST NOT be more than one property or constant declared per |
||
1553 | * statement. |
||
1554 | */ |
||
1555 | 'single_class_element_per_statement' => [ |
||
1556 | 'elements' => [ |
||
1557 | 'property', |
||
1558 | ], |
||
1559 | ], |
||
1560 | |||
1561 | // There MUST be one use keyword per declaration. |
||
1562 | 'single_import_per_statement' => true, |
||
1563 | |||
1564 | /* |
||
1565 | * Each namespace use MUST go on its own line and there MUST be one |
||
1566 | * blank line after the use statements block. |
||
1567 | */ |
||
1568 | 'single_line_after_imports' => true, |
||
1569 | |||
1570 | /* |
||
1571 | * Single-line comments and multi-line comments with only one line |
||
1572 | * of actual content should use the `//` syntax. |
||
1573 | */ |
||
1574 | 'single_line_comment_style' => true, |
||
1575 | |||
1576 | // Throwing exception must be done in single line. |
||
1577 | 'single_line_throw' => false, |
||
1578 | |||
1579 | // Convert double quotes to single quotes for simple strings. |
||
1580 | 'single_quote' => [ |
||
1581 | 'strings_containing_single_quote_chars' => false, |
||
1582 | ], |
||
1583 | |||
1584 | // Ensures a single space after language constructs. |
||
1585 | 'single_space_after_construct' => true, |
||
1586 | |||
1587 | // Each trait `use` must be done as single statement. |
||
1588 | 'single_trait_insert_per_statement' => true, |
||
1589 | |||
1590 | // Fix whitespace after a semicolon. |
||
1591 | 'space_after_semicolon' => true, |
||
1592 | |||
1593 | // Increment and decrement operators should be used if possible. |
||
1594 | 'standardize_increment' => true, |
||
1595 | |||
1596 | // Replace all `<>` with `!=`. |
||
1597 | 'standardize_not_equals' => true, |
||
1598 | |||
1599 | /* |
||
1600 | * Lambdas not (indirect) referencing `$this` must be declared |
||
1601 | * `static`. |
||
1602 | * |
||
1603 | * Risky! |
||
1604 | * Risky when using `->bindTo` on lambdas without referencing to |
||
1605 | * `$this`. |
||
1606 | */ |
||
1607 | 'static_lambda' => true, |
||
1608 | |||
1609 | /* |
||
1610 | * Comparisons should be strict. |
||
1611 | * |
||
1612 | * Risky! |
||
1613 | * Changing comparisons to strict might change code behavior. |
||
1614 | */ |
||
1615 | 'strict_comparison' => true, |
||
1616 | |||
1617 | /* |
||
1618 | * Functions should be used with `$strict` param set to `true`. |
||
1619 | * |
||
1620 | * The functions "array_keys", "array_search", "base64_decode", |
||
1621 | * "in_array" and "mb_detect_encoding" should be used with $strict |
||
1622 | * param. |
||
1623 | * |
||
1624 | * Risky! |
||
1625 | * Risky when the fixed function is overridden or if the code relies |
||
1626 | * on non-strict usage. |
||
1627 | */ |
||
1628 | 'strict_param' => true, |
||
1629 | |||
1630 | /* |
||
1631 | * String tests for empty must be done against `''`, not with |
||
1632 | * `strlen`. |
||
1633 | * |
||
1634 | * Risky! |
||
1635 | * Risky when `strlen` is overridden, when called using a |
||
1636 | * `stringable` object, also no longer triggers warning when called |
||
1637 | * using non-string(able). |
||
1638 | */ |
||
1639 | 'string_length_to_empty' => true, |
||
1640 | |||
1641 | /* |
||
1642 | * All multi-line strings must use correct line ending. |
||
1643 | * |
||
1644 | * Risky! |
||
1645 | * Changing the line endings of multi-line strings might affect |
||
1646 | * string comparisons and outputs. |
||
1647 | */ |
||
1648 | 'string_line_ending' => true, |
||
1649 | |||
1650 | // A case should be followed by a colon and not a semicolon. |
||
1651 | 'switch_case_semicolon_to_colon' => true, |
||
1652 | |||
1653 | // Removes extra spaces between colon and case value. |
||
1654 | 'switch_case_space' => true, |
||
1655 | |||
1656 | // Switch case must not be ended with `continue` but with `break`. |
||
1657 | 'switch_continue_to_break' => true, |
||
1658 | |||
1659 | // Standardize spaces around ternary operator. |
||
1660 | 'ternary_operator_spaces' => true, |
||
1661 | |||
1662 | /* |
||
1663 | * Use the Elvis operator `?:` where possible. |
||
1664 | * |
||
1665 | * Risky! |
||
1666 | * Risky when relying on functions called on both sides of the `?` |
||
1667 | * operator. |
||
1668 | */ |
||
1669 | 'ternary_to_elvis_operator' => true, |
||
1670 | |||
1671 | /* |
||
1672 | * Use `null` coalescing operator `??` where possible. Requires PHP |
||
1673 | * >= 7.0. |
||
1674 | */ |
||
1675 | 'ternary_to_null_coalescing' => true, |
||
1676 | |||
1677 | /* |
||
1678 | * Multi-line arrays, arguments list and parameters list must have a |
||
1679 | * trailing comma. |
||
1680 | */ |
||
1681 | 'trailing_comma_in_multiline' => true, |
||
1682 | |||
1683 | /* |
||
1684 | * Arrays should be formatted like function/method arguments, |
||
1685 | * without leading or trailing single line space. |
||
1686 | */ |
||
1687 | 'trim_array_spaces' => true, |
||
1688 | |||
1689 | // A single space or none should be around union type operator. |
||
1690 | 'types_spaces' => true, |
||
1691 | |||
1692 | // Unary operators should be placed adjacent to their operands. |
||
1693 | 'unary_operator_spaces' => true, |
||
1694 | |||
1695 | /* |
||
1696 | * Anonymous functions with one-liner return statement must use |
||
1697 | * arrow functions. |
||
1698 | * |
||
1699 | * Risky! |
||
1700 | * Risky when using `isset()` on outside variables that are not |
||
1701 | * imported with `use ()`. |
||
1702 | */ |
||
1703 | 'use_arrow_functions' => true, |
||
1704 | |||
1705 | /* |
||
1706 | * Visibility MUST be declared on all properties and methods; |
||
1707 | * `abstract` and `final` MUST be declared before the visibility; |
||
1708 | * `static` MUST be declared after the visibility. |
||
1709 | */ |
||
1710 | 'visibility_required' => [ |
||
1711 | 'elements' => [ |
||
1712 | 'const', |
||
1713 | 'method', |
||
1714 | 'property', |
||
1715 | ], |
||
1716 | ], |
||
1717 | |||
1718 | /* |
||
1719 | * Add `void` return type to functions with missing or empty return |
||
1720 | * statements, but priority is given to `@return` annotations. |
||
1721 | * Requires PHP >= 7.1. |
||
1722 | * |
||
1723 | * Risky! |
||
1724 | * Modifies the signature of functions. |
||
1725 | */ |
||
1726 | 'void_return' => true, |
||
1727 | |||
1728 | /* |
||
1729 | * In array declaration, there MUST be a whitespace after each |
||
1730 | * comma. |
||
1731 | */ |
||
1732 | 'whitespace_after_comma_in_array' => true, |
||
1733 | |||
1734 | /* |
||
1735 | * Write conditions in Yoda style (`true`), non-Yoda style |
||
1736 | * (`['equal' => false, 'identical' => false, 'less_and_greater' => |
||
1737 | * false]`) or ignore those conditions (`null`) based on |
||
1738 | * configuration. |
||
1739 | */ |
||
1740 | 'yoda_style' => [ |
||
1741 | 'equal' => false, |
||
1742 | 'identical' => false, |
||
1743 | 'less_and_greater' => false, |
||
1744 | ], |
||
1745 | ]; |
||
1746 | |||
1747 | if (\PHP_SAPI === 'cli' && !class_exists(\PhpCsFixer\Config::class)) { |
||
0 ignored issues
–
show
|
|||
1748 | $which = static function ($program, $default = null) { |
||
1749 | exec(sprintf('command -v %s', escapeshellarg($program)), $output, $resultCode); |
||
1750 | if ($resultCode === 0) { |
||
1751 | return trim($output[0]); |
||
1752 | } |
||
1753 | |||
1754 | return $default; |
||
1755 | }; |
||
1756 | $findExistsFile = static function (array $files): ?string { |
||
1757 | foreach ($files as $file) { |
||
1758 | if ($file !== null && is_file($file)) { |
||
1759 | return $file; |
||
1760 | } |
||
1761 | } |
||
1762 | |||
1763 | return null; |
||
1764 | }; |
||
1765 | |||
1766 | $fixerBinaries = [ |
||
1767 | __DIR__ . '/vendor/bin/php-cs-fixer', |
||
1768 | __DIR__ . '/tools/php-cs-fixer/vendor/bin/php-cs-fixer', |
||
1769 | $which('php-cs-fixer'), |
||
1770 | isset($_SERVER['COMPOSER_HOME']) ? $_SERVER['COMPOSER_HOME'] . '/vendor/bin/php-cs-fixer' : null, |
||
1771 | ]; |
||
1772 | $fixerBin = $findExistsFile($fixerBinaries) ?? 'php-cs-fixer'; |
||
1773 | $phpBin = $_SERVER['_'] ?? 'php'; |
||
1774 | |||
1775 | $dryRun = !in_array('--force', $_SERVER['argv'], true); |
||
1776 | $commandFormat = '%s %s fix --config %s --diff --ansi -vv%s'; |
||
1777 | $command = sprintf( |
||
1778 | $commandFormat, |
||
1779 | escapeshellarg($phpBin), |
||
1780 | escapeshellarg($fixerBin), |
||
1781 | escapeshellarg(__FILE__), |
||
1782 | $dryRun ? ' --dry-run' : '' |
||
1783 | ); |
||
1784 | $outputCommand = sprintf( |
||
1785 | $commandFormat, |
||
1786 | $phpBin, |
||
1787 | strpos($fixerBin, ' ') === false ? $fixerBin : escapeshellarg($fixerBin), |
||
1788 | escapeshellarg(__FILE__), |
||
1789 | $dryRun ? ' --dry-run' : '' |
||
1790 | ); |
||
1791 | |||
1792 | fwrite(\STDOUT, "\e[22;94m" . $outputCommand . "\e[m\n\n"); |
||
1793 | system($command, $returnCode); |
||
1794 | |||
1795 | if ($dryRun || $returnCode === 8) { |
||
1796 | fwrite(\STDOUT, "\n\e[1;40;93m\e[K\n"); |
||
1797 | fwrite(\STDOUT, " [DEBUG] Dry run php-cs-fixer config.\e[K\n"); |
||
1798 | fwrite(\STDOUT, " Only shows which files would have been modified.\e[K\n"); |
||
1799 | fwrite(\STDOUT, " To apply the rules, use the --force option:\e[K\n\e[K\n"); |
||
1800 | fwrite( |
||
1801 | \STDOUT, |
||
1802 | sprintf( |
||
1803 | " \e[1;40;92m%s %s --force\e[K\n\e[0m\n", |
||
1804 | basename($phpBin), |
||
1805 | $_SERVER['argv'][0] |
||
1806 | ) |
||
1807 | ); |
||
1808 | } elseif ($returnCode !== 0) { |
||
1809 | fwrite(\STDERR, sprintf("\n\e[1;41;97m\e[K\n ERROR CODE: %s\e[K\n\e[0m\n", $returnCode)); |
||
1810 | } |
||
1811 | |||
1812 | exit($returnCode); |
||
1813 | } |
||
1814 | |||
1815 | return (new \PhpCsFixer\Config()) |
||
1816 | ->setUsingCache(true) |
||
1817 | ->setCacheFile(__DIR__ . '/.php-cs-fixer.cache') |
||
1818 | ->setRules($rules) |
||
1819 | ->setRiskyAllowed(true) |
||
1820 | ->setFinder( |
||
1821 | \PhpCsFixer\Finder::create() |
||
0 ignored issues
–
show
The type
PhpCsFixer\Finder was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
1822 | ->ignoreUnreadableDirs() |
||
1823 | ->exclude('.github') |
||
1824 | ->exclude('tools') |
||
1825 | ->exclude('var') |
||
1826 | ->exclude('node_modules') |
||
1827 | ->name('/\\.php$/') |
||
1828 | ->name('/\\.php$/') |
||
1829 | ->name('/\\.php$/') |
||
1830 | ->notPath('src/DependencyInjection/Configuration.php') |
||
1831 | ->in(__DIR__) |
||
1832 | ) |
||
1833 | ; |
||
1834 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths