|
8 | 8 | ->ignoreDotFiles(true)
|
9 | 9 | ->ignoreVCS(true);
|
10 | 10 |
|
11 |
| -return (new PhpCsFixer\Config) |
| 11 | +return (new PhpCsFixer\Config()) |
12 | 12 | ->setRiskyAllowed(true)
|
13 | 13 | ->setRules([
|
14 |
| - '@PSR1' => false, |
15 |
| - '@PSR2' => true, |
| 14 | + '@PSR12' => true, |
16 | 15 |
|
17 | 16 | /**
|
18 |
| - * symfony |
| 17 | + * Array Notation. |
| 18 | + */ |
| 19 | + // PHP arrays should be declared using the configured syntax. |
| 20 | + 'array_syntax' => ['syntax' => 'short'], |
| 21 | + |
| 22 | + /** |
| 23 | + * Cast Notation. |
| 24 | + */ |
| 25 | + // A single space should be between cast and variable. |
| 26 | + 'cast_spaces' => true, |
| 27 | + |
| 28 | + /** |
| 29 | + * Class Notation. |
| 30 | + */ |
| 31 | + // Methods must be separated with one blank line. |
| 32 | + 'class_attributes_separation' => true, |
| 33 | + |
| 34 | + /** |
| 35 | + * Control Structure. |
19 | 36 | */
|
20 |
| - // Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline. |
21 |
| - 'blank_line_after_opening_tag' => true, |
22 |
| - // Remove duplicated semicolons. |
23 |
| - 'no_empty_statement' => true, |
24 | 37 | // PHP multi-line arrays should have a trailing comma.
|
25 | 38 | 'trailing_comma_in_multiline' => true,
|
26 |
| - // There should be no empty lines after class opening brace. |
27 |
| - 'no_blank_lines_after_class_opening' => true, |
| 39 | + |
| 40 | + /** |
| 41 | + * Function Notation. |
| 42 | + */ |
| 43 | + // In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after each comma. Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. |
| 44 | + 'method_argument_space' => [ |
| 45 | + 'on_multiline' => 'ensure_fully_multiline', |
| 46 | + 'keep_multiple_spaces_after_comma' => true, |
| 47 | + ], |
| 48 | + |
| 49 | + /** |
| 50 | + * Import. |
| 51 | + */ |
| 52 | + // Unused use statements must be removed. |
| 53 | + 'no_unused_imports' => true, |
| 54 | + // Ordering use statements. |
| 55 | + 'ordered_imports' => ['sort_algorithm' => 'alpha'], |
| 56 | + // Transforms imported FQCN parameters and return types in function arguments to short version. |
| 57 | + 'fully_qualified_strict_types' => true, |
| 58 | + // Imports or fully qualifies global classes/functions/constants. |
| 59 | + 'global_namespace_import' => [ |
| 60 | + 'import_classes' => true, |
| 61 | + 'import_constants' => null, |
| 62 | + 'import_functions' => null, |
| 63 | + ], |
| 64 | + |
| 65 | + /** |
| 66 | + * Operator. |
| 67 | + */ |
| 68 | + // Unary operators should be placed adjacent to their operands. |
| 69 | + 'unary_operator_spaces' => true, |
| 70 | + // Binary operators should be surrounded by at least one space. |
| 71 | + 'binary_operator_spaces' => true, |
| 72 | + // Concatenation should be used with at least one whitespace around. |
| 73 | + 'concat_space' => ['spacing' => 'one'], |
| 74 | + // Logical NOT operators `(!)` should have one trailing whitespace. |
| 75 | + 'not_operator_with_successor_space' => true, |
| 76 | + |
| 77 | + /** |
| 78 | + * PHPDoc. |
| 79 | + */ |
| 80 | + // Scalar types should always be written in the same form. int not integer, bool not boolean, float not real or double. |
| 81 | + 'phpdoc_scalar' => true, |
| 82 | + // Single line @var PHPDoc should have proper spacing. |
| 83 | + 'phpdoc_single_line_var_spacing' => true, |
| 84 | + // @var and @type annotations of classy properties should not contain the name. |
| 85 | + 'phpdoc_var_without_name' => true, |
28 | 86 | // There should not be blank lines between docblock and the documented element.
|
29 | 87 | 'no_blank_lines_after_phpdoc' => true,
|
30 | 88 | // Phpdocs short descriptions should end in either a full stop, exclamation mark, or question mark.
|
31 | 89 | 'phpdoc_summary' => true,
|
32 | 90 | // Phpdocs should start and end with content, excluding the very first and last line of the docblocks.
|
33 | 91 | 'phpdoc_trim' => true,
|
34 |
| - // Removes line breaks between use statements. |
35 |
| - 'no_extra_blank_lines' => ['tokens' => ['use']], |
36 |
| - // An empty line feed should precede a return statement. |
37 |
| - 'blank_line_before_statement' => true, |
38 |
| - // There should be exactly one blank line before a namespace declaration. |
39 |
| - 'single_blank_line_before_namespace' => true, |
| 92 | + |
| 93 | + /** |
| 94 | + * Semicolon. |
| 95 | + */ |
| 96 | + // Remove duplicated semicolons. |
| 97 | + 'no_empty_statement' => true, |
| 98 | + |
| 99 | + /** |
| 100 | + * String Notation. |
| 101 | + */ |
40 | 102 | // Convert double quotes to single quotes for simple strings.
|
41 | 103 | 'single_quote' => true,
|
42 |
| - // Unused use statements must be removed. |
43 |
| - 'no_unused_imports' => true, |
44 |
| - // Methods must be separated with one blank line. |
45 |
| - 'class_attributes_separation' => true, |
46 |
| - // Binary operators should be surrounded by at least one space. |
47 |
| - 'binary_operator_spaces' => ['operators' => ['=>' => 'single_space']], |
48 |
| - // A single space should be between cast and variable. |
49 |
| - 'cast_spaces' => true, |
50 | 104 |
|
51 | 105 | /**
|
52 |
| - * contrib |
| 106 | + * Whitespace. |
53 | 107 | */
|
54 |
| - // Concatenation should be used with at least one whitespace around. |
55 |
| - 'concat_space' => ['spacing' => 'one'], |
56 |
| - // Ordering use statements. |
57 |
| - 'ordered_imports' => true, |
58 |
| - // PHP arrays should be declared using the configured syntax. |
59 |
| - 'array_syntax' => ['syntax' => 'short'] |
| 108 | + // An empty line feed should precede a return statement. |
| 109 | + 'blank_line_before_statement' => [ |
| 110 | + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], |
| 111 | + ], |
| 112 | + // Removes line breaks between use statements. |
| 113 | + 'no_extra_blank_lines' => ['tokens' => ['use']], |
60 | 114 | ])
|
61 | 115 | ->setFinder($finder)
|
62 | 116 | ->setUsingCache(true);
|
0 commit comments