|
3 | 3 | use PhpCsFixer\Finder; |
4 | 4 | use PhpCsFixer\Config; |
5 | 5 |
|
6 | | -$finder = Finder::create()->in(__DIR__) |
7 | | - ->exclude('docs'); |
| 6 | +$finder = Finder::create() |
| 7 | + ->exclude([ |
| 8 | + __DIR__ . '/docs/', |
| 9 | + __DIR__ . '/vendor/', |
| 10 | + ]) |
| 11 | + ->in(__DIR__) |
| 12 | + ->append([ |
| 13 | + __FILE__, |
| 14 | + ]); |
8 | 15 |
|
9 | 16 | $config = new Config(); |
| 17 | +$config |
| 18 | + ->setCacheFile(__DIR__ . '/runtime/.php-cs-fixer.cache') |
| 19 | + ->setRules( |
| 20 | + [ |
| 21 | + '@PSR2' => true, |
| 22 | + '@PHP84Migration' => true, |
| 23 | + 'align_multiline_comment' => true, |
| 24 | + 'array_syntax' => ['syntax' => 'short'], |
| 25 | + 'backtick_to_shell_exec' => true, |
| 26 | + 'binary_operator_spaces' => true, |
| 27 | + 'blank_lines_before_namespace' => true, |
| 28 | + 'blank_line_after_namespace' => true, |
| 29 | + 'blank_line_after_opening_tag' => true, |
| 30 | + 'blank_line_before_statement' => [ |
| 31 | + 'statements' => [ |
| 32 | + 'break', 'case', 'continue', 'declare', 'default', 'do', 'for', |
| 33 | + 'if', 'foreach', 'return', 'switch', 'try', 'while', |
| 34 | + ], |
| 35 | + ], |
| 36 | + 'cast_spaces' => ['space' => 'single'], |
| 37 | + 'class_attributes_separation' => true, |
| 38 | + 'combine_consecutive_issets' => true, |
| 39 | + 'combine_consecutive_unsets' => true, |
| 40 | + 'compact_nullable_type_declaration' => true, |
| 41 | + 'concat_space' => ['spacing' => 'one'], |
| 42 | + 'fully_qualified_strict_types' => true, |
| 43 | + 'increment_style' => ['style' => 'pre'], |
| 44 | + 'linebreak_after_opening_tag' => true, |
| 45 | + 'list_syntax' => ['syntax' => 'short'], |
| 46 | + 'lowercase_cast' => true, |
| 47 | + 'lowercase_static_reference' => true, |
| 48 | + 'magic_constant_casing' => true, |
| 49 | + 'magic_method_casing' => true, |
| 50 | + 'multiline_comment_opening_closing' => true, |
| 51 | + 'multiline_whitespace_before_semicolons' => [ |
| 52 | + 'strategy' => 'no_multi_line', |
| 53 | + ], |
| 54 | + 'native_function_casing' => true, |
| 55 | + 'native_type_declaration_casing' => true, |
| 56 | + 'new_with_parentheses' => true, |
| 57 | + 'no_alternative_syntax' => true, |
| 58 | + 'no_blank_lines_after_class_opening' => true, |
| 59 | + 'no_blank_lines_after_phpdoc' => true, |
| 60 | + 'no_empty_statement' => true, |
| 61 | + 'no_extra_blank_lines' => true, |
| 62 | + 'no_leading_import_slash' => true, |
| 63 | + 'no_leading_namespace_whitespace' => true, |
| 64 | + 'no_mixed_echo_print' => ['use' => 'echo'], |
| 65 | + 'no_null_property_initialization' => true, |
| 66 | + 'no_short_bool_cast' => true, |
| 67 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 68 | + 'no_spaces_around_offset' => true, |
| 69 | + 'no_superfluous_phpdoc_tags' => false, |
| 70 | + 'no_superfluous_elseif' => true, |
| 71 | + 'no_trailing_comma_in_singleline' => true, |
| 72 | + 'no_unneeded_control_parentheses' => true, |
| 73 | + 'no_unneeded_braces' => true, |
| 74 | + 'no_unset_cast' => true, |
| 75 | + 'no_unused_imports' => true, |
| 76 | + 'no_useless_else' => true, |
| 77 | + 'no_useless_return' => true, |
| 78 | + 'no_whitespace_before_comma_in_array' => true, |
| 79 | + 'no_whitespace_in_blank_line' => true, |
| 80 | + 'normalize_index_brace' => true, |
| 81 | + 'nullable_type_declaration_for_default_null_value' => true, |
| 82 | + 'object_operator_without_whitespace' => true, |
| 83 | + 'ordered_class_elements' => [ |
| 84 | + 'order' => [ |
| 85 | + 'use_trait', 'constant_public', 'constant_protected', |
| 86 | + 'constant_private', 'property_public_static', 'property_protected_static', |
| 87 | + 'property_private_static', 'property_public', 'property_protected', |
| 88 | + 'property_private', 'method_public_static', 'method_protected_static', |
| 89 | + 'method_private_static', 'construct', 'destruct', 'phpunit', |
| 90 | + 'method_public', 'method_protected', 'method_private', 'magic', |
| 91 | + ], |
| 92 | + 'sort_algorithm' => 'none', |
| 93 | + ], |
| 94 | + 'php_unit_fqcn_annotation' => true, |
| 95 | + 'php_unit_method_casing' => ['case' => 'camel_case'], |
| 96 | + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], |
| 97 | + 'phpdoc_align' => ['align' => 'left'], |
| 98 | + 'phpdoc_line_span' => [ |
| 99 | + 'const' => 'multi', |
| 100 | + 'method' => 'multi', |
| 101 | + 'property' => 'multi', |
| 102 | + ], |
| 103 | + 'phpdoc_no_access' => true, |
| 104 | + 'phpdoc_no_empty_return' => true, |
| 105 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 106 | + 'phpdoc_order' => true, |
| 107 | + 'phpdoc_scalar' => true, |
| 108 | + 'phpdoc_single_line_var_spacing' => true, |
| 109 | + 'phpdoc_to_comment' => false, |
| 110 | + 'phpdoc_trim' => true, |
| 111 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 112 | + 'phpdoc_var_without_name' => true, |
| 113 | + 'protected_to_private' => true, |
| 114 | + 'return_assignment' => false, |
| 115 | + 'return_type_declaration' => ['space_before' => 'one'], |
| 116 | + 'semicolon_after_instruction' => true, |
| 117 | + 'short_scalar_cast' => true, |
| 118 | + 'simplified_null_return' => true, |
| 119 | + 'single_quote' => true, |
| 120 | + 'single_line_comment_style' => true, |
| 121 | + 'ternary_operator_spaces' => true, |
| 122 | + 'ternary_to_null_coalescing' => true, |
| 123 | + 'type_declaration_spaces' => true, |
| 124 | + 'trim_array_spaces' => true, |
| 125 | + 'unary_operator_spaces' => true, |
| 126 | + 'whitespace_after_comma_in_array' => true, |
| 127 | + ] |
| 128 | + )->setFinder($finder); |
10 | 129 |
|
11 | | -return $config->setRules([ |
12 | | - '@PSR2' => true, |
13 | | - 'align_multiline_comment' => true, |
14 | | - 'array_syntax' => ['syntax' => 'short'], |
15 | | - 'backtick_to_shell_exec' => true, |
16 | | - 'binary_operator_spaces' => true, |
17 | | - 'blank_lines_before_namespace' => true, |
18 | | - 'blank_line_after_namespace' => true, |
19 | | - 'blank_line_after_opening_tag' => true, |
20 | | - 'blank_line_before_statement' => [ |
21 | | - 'statements' => [ |
22 | | - 'break', 'case', 'continue', 'declare', 'default', 'do', 'for', |
23 | | - 'if', 'foreach', 'return', 'switch', 'try', 'while', |
24 | | - ], |
25 | | - ], |
26 | | - 'cast_spaces' => ['space' => 'single'], |
27 | | - 'class_attributes_separation' => true, |
28 | | - 'combine_consecutive_issets' => true, |
29 | | - 'combine_consecutive_unsets' => true, |
30 | | - 'compact_nullable_type_declaration' => true, |
31 | | - 'concat_space' => ['spacing' => 'one'], |
32 | | - 'fully_qualified_strict_types' => true, |
33 | | - 'increment_style' => ['style' => 'pre'], |
34 | | - 'linebreak_after_opening_tag' => true, |
35 | | - 'list_syntax' => ['syntax' => 'short'], |
36 | | - 'lowercase_cast' => true, |
37 | | - 'lowercase_static_reference' => true, |
38 | | - 'magic_constant_casing' => true, |
39 | | - 'magic_method_casing' => true, |
40 | | - 'multiline_comment_opening_closing' => true, |
41 | | - 'multiline_whitespace_before_semicolons' => [ |
42 | | - 'strategy' => 'no_multi_line', |
43 | | - ], |
44 | | - 'native_function_casing' => true, |
45 | | - 'native_type_declaration_casing' => true, |
46 | | - 'new_with_parentheses' => true, |
47 | | - 'no_alternative_syntax' => true, |
48 | | - 'no_blank_lines_after_class_opening' => true, |
49 | | - 'no_blank_lines_after_phpdoc' => true, |
50 | | - 'no_empty_statement' => true, |
51 | | - 'no_extra_blank_lines' => true, |
52 | | - 'no_leading_import_slash' => true, |
53 | | - 'no_leading_namespace_whitespace' => true, |
54 | | - 'no_mixed_echo_print' => ['use' => 'echo'], |
55 | | - 'no_null_property_initialization' => true, |
56 | | - 'no_short_bool_cast' => true, |
57 | | - 'no_singleline_whitespace_before_semicolons' => true, |
58 | | - 'no_spaces_around_offset' => true, |
59 | | - 'no_superfluous_phpdoc_tags' => false, |
60 | | - 'no_superfluous_elseif' => true, |
61 | | - 'no_trailing_comma_in_singleline' => true, |
62 | | - 'no_unneeded_control_parentheses' => true, |
63 | | - 'no_unneeded_braces' => true, |
64 | | - 'no_unset_cast' => true, |
65 | | - 'no_unused_imports' => true, |
66 | | - 'no_useless_else' => true, |
67 | | - 'no_useless_return' => true, |
68 | | - 'no_whitespace_before_comma_in_array' => true, |
69 | | - 'no_whitespace_in_blank_line' => true, |
70 | | - 'normalize_index_brace' => true, |
71 | | - 'nullable_type_declaration_for_default_null_value' => true, |
72 | | - 'object_operator_without_whitespace' => true, |
73 | | - 'ordered_class_elements' => [ |
74 | | - 'order' => [ |
75 | | - 'use_trait', 'constant_public', 'constant_protected', |
76 | | - 'constant_private', 'property_public_static', 'property_protected_static', |
77 | | - 'property_private_static', 'property_public', 'property_protected', |
78 | | - 'property_private', 'method_public_static', 'method_protected_static', |
79 | | - 'method_private_static', 'construct', 'destruct', 'phpunit', |
80 | | - 'method_public', 'method_protected', 'method_private', 'magic', |
81 | | - ], |
82 | | - 'sort_algorithm' => 'none', |
83 | | - ], |
84 | | - 'php_unit_fqcn_annotation' => true, |
85 | | - 'php_unit_method_casing' => ['case' => 'camel_case'], |
86 | | - 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], |
87 | | - 'phpdoc_align' => ['align' => 'left'], |
88 | | - 'phpdoc_line_span' => [ |
89 | | - 'const' => 'multi', |
90 | | - 'method' => 'multi', |
91 | | - 'property' => 'multi', |
92 | | - ], |
93 | | - 'phpdoc_no_access' => true, |
94 | | - 'phpdoc_no_empty_return' => true, |
95 | | - 'phpdoc_no_useless_inheritdoc' => true, |
96 | | - 'phpdoc_order' => true, |
97 | | - 'phpdoc_scalar' => true, |
98 | | - 'phpdoc_single_line_var_spacing' => true, |
99 | | - 'phpdoc_to_comment' => false, |
100 | | - 'phpdoc_trim' => true, |
101 | | - 'phpdoc_trim_consecutive_blank_line_separation' => true, |
102 | | - 'phpdoc_var_without_name' => true, |
103 | | - 'protected_to_private' => true, |
104 | | - 'return_assignment' => false, |
105 | | - 'return_type_declaration' => ['space_before' => 'one'], |
106 | | - 'semicolon_after_instruction' => true, |
107 | | - 'short_scalar_cast' => true, |
108 | | - 'simplified_null_return' => true, |
109 | | - 'single_quote' => true, |
110 | | - 'single_line_comment_style' => true, |
111 | | - 'ternary_operator_spaces' => true, |
112 | | - 'ternary_to_null_coalescing' => true, |
113 | | - 'type_declaration_spaces' => true, |
114 | | - 'trim_array_spaces' => true, |
115 | | - 'unary_operator_spaces' => true, |
116 | | - 'whitespace_after_comma_in_array' => true, |
117 | | -])->setFinder($finder); |
| 130 | +return $config; |
0 commit comments