|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
5 | | -return (new PhpCsFixer\Config()) |
| 5 | +use PhpCsFixer\Config; |
| 6 | +use PhpCsFixer\Finder; |
| 7 | + |
| 8 | +return (new Config()) |
6 | 9 | ->setRiskyAllowed(true) |
7 | 10 | ->setRules([ |
8 | 11 | '@PSR2' => true, |
9 | 12 | '@Symfony' => true, |
10 | 13 | '@DoctrineAnnotation' => true, |
11 | 14 | '@PhpCsFixer' => true, |
12 | | - 'global_namespace_import' => [ |
13 | | - 'import_classes' => true, |
14 | | - 'import_constants' => true, |
15 | | - 'import_functions' => null, |
| 15 | + 'array_syntax' => [ |
| 16 | + 'syntax' => 'short', |
16 | 17 | ], |
17 | | - 'array_indentation' => true, |
18 | | - 'array_syntax' => ['syntax' => 'short'], |
19 | | - 'binary_operator_spaces' => [ |
20 | | - 'default' => 'single_space', |
| 18 | + 'list_syntax' => [ |
| 19 | + 'syntax' => 'short', |
| 20 | + ], |
| 21 | + 'concat_space' => [ |
| 22 | + 'spacing' => 'one', |
21 | 23 | ], |
22 | | - 'blank_line_after_namespace' => true, |
23 | | - 'blank_line_after_opening_tag' => true, |
24 | 24 | 'blank_line_before_statement' => [ |
25 | 25 | 'statements' => [ |
26 | | - 'continue', |
27 | | - 'return', |
| 26 | + 'declare', |
28 | 27 | ], |
29 | 28 | ], |
30 | | - 'blank_lines_before_namespace' => true, |
31 | | - 'control_structure_braces' => true, |
32 | | - 'control_structure_continuation_position' => [ |
33 | | - 'position' => 'same_line', |
34 | | - ], |
35 | | - 'curly_braces_position' => [ |
36 | | - 'control_structures_opening_brace' => 'same_line', |
37 | | - 'functions_opening_brace' => 'next_line_unless_newline_at_signature_end', |
38 | | - 'anonymous_functions_opening_brace' => 'same_line', |
39 | | - 'classes_opening_brace' => 'next_line_unless_newline_at_signature_end', |
40 | | - 'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end', |
41 | | - 'allow_single_line_empty_anonymous_classes' => false, |
42 | | - 'allow_single_line_anonymous_functions' => false, |
43 | | - ], |
44 | | - 'cast_spaces' => true, |
45 | | - 'class_attributes_separation' => [ |
46 | | - 'elements' => [ |
47 | | - 'const' => 'one', |
48 | | - 'method' => 'one', |
49 | | - 'property' => 'one', |
50 | | - 'trait_import' => 'none', |
| 29 | + 'general_phpdoc_annotation_remove' => [ |
| 30 | + 'annotations' => [ |
| 31 | + 'author', |
51 | 32 | ], |
52 | 33 | ], |
53 | | - 'class_definition' => [ |
54 | | - 'multi_line_extends_each_single_line' => true, |
55 | | - 'single_item_single_line' => true, |
56 | | - 'single_line' => true, |
57 | | - ], |
58 | | - 'clean_namespace' => true, |
59 | | - 'compact_nullable_typehint' => true, |
60 | | - 'concat_space' => [ |
61 | | - 'spacing' => 'one', |
| 34 | + 'ordered_imports' => [ |
| 35 | + 'imports_order' => [ |
| 36 | + 'class', 'function', 'const', |
| 37 | + ], |
| 38 | + 'sort_algorithm' => 'alpha', |
62 | 39 | ], |
63 | | - 'constant_case' => ['case' => 'lower'], |
64 | | - 'declare_equal_normalize' => true, |
65 | | - 'declare_parentheses' => true, |
66 | | - 'elseif' => true, |
67 | | - 'encoding' => true, |
68 | | - 'full_opening_tag' => true, |
69 | | - 'fully_qualified_strict_types' => true, |
70 | | - 'function_declaration' => true, |
71 | | - 'general_phpdoc_tag_rename' => true, |
72 | | - 'heredoc_to_nowdoc' => true, |
73 | | - 'include' => true, |
74 | | - 'increment_style' => ['style' => 'post'], |
75 | | - 'indentation_type' => true, |
76 | | - 'integer_literal_case' => true, |
77 | | - 'lambda_not_used_import' => true, |
78 | | - 'linebreak_after_opening_tag' => true, |
79 | | - 'line_ending' => true, |
80 | | - 'list_syntax' => true, |
81 | | - 'lowercase_cast' => true, |
82 | | - 'lowercase_keywords' => true, |
83 | | - 'lowercase_static_reference' => true, |
84 | | - 'magic_method_casing' => true, |
85 | | - 'magic_constant_casing' => true, |
86 | | - 'method_argument_space' => [ |
87 | | - 'on_multiline' => 'ignore', |
| 40 | + 'yoda_style' => [ |
| 41 | + 'always_move_variable' => false, |
| 42 | + 'equal' => false, |
| 43 | + 'identical' => false, |
88 | 44 | ], |
89 | | - 'method_chaining_indentation' => true, |
90 | 45 | 'multiline_whitespace_before_semicolons' => [ |
91 | 46 | 'strategy' => 'no_multi_line', |
92 | 47 | ], |
93 | | - 'native_function_casing' => true, |
94 | | - 'native_function_type_declaration_casing' => true, |
95 | | - 'no_alias_functions' => true, |
96 | | - 'no_alias_language_construct_call' => true, |
97 | | - 'no_alternative_syntax' => true, |
98 | | - 'no_binary_string' => true, |
99 | | - 'no_blank_lines_after_class_opening' => true, |
100 | | - 'no_blank_lines_after_phpdoc' => true, |
101 | | - 'no_closing_tag' => true, |
102 | | - 'no_empty_phpdoc' => true, |
103 | | - 'no_empty_statement' => true, |
| 48 | + 'constant_case' => [ |
| 49 | + 'case' => 'lower', |
| 50 | + ], |
| 51 | + 'class_attributes_separation' => true, |
| 52 | + 'combine_consecutive_unsets' => true, |
| 53 | + // 注释结尾是否必须要加句号 |
| 54 | + 'phpdoc_summary' => false, |
| 55 | + // 文件严格模式 |
| 56 | + 'declare_strict_types' => true, |
| 57 | + 'linebreak_after_opening_tag' => true, |
| 58 | + 'lowercase_static_reference' => true, |
104 | 59 | 'no_extra_blank_lines' => [ |
105 | 60 | 'tokens' => [ |
| 61 | + 'attribute', |
| 62 | + 'break', |
| 63 | + 'case', |
| 64 | + 'continue', |
| 65 | + 'curly_brace_block', |
| 66 | + 'default', |
106 | 67 | 'extra', |
| 68 | + 'parenthesis_brace_block', |
| 69 | + 'return', |
| 70 | + 'square_brace_block', |
| 71 | + 'switch', |
107 | 72 | 'throw', |
108 | | - 'use', |
| 73 | + 'use' |
109 | 74 | ], |
110 | 75 | ], |
111 | | - 'no_leading_import_slash' => true, |
112 | | - 'no_leading_namespace_whitespace' => true, |
113 | | - 'no_mixed_echo_print' => [ |
114 | | - 'use' => 'echo', |
115 | | - ], |
116 | | - 'no_multiline_whitespace_around_double_arrow' => true, |
117 | | - 'no_multiple_statements_per_line' => true, |
118 | | - 'no_short_bool_cast' => true, |
119 | | - 'no_singleline_whitespace_before_semicolons' => true, |
120 | | - 'no_spaces_after_function_name' => true, |
121 | | - 'no_space_around_double_colon' => true, |
122 | | - 'no_spaces_around_offset' => [ |
123 | | - 'positions' => ['inside', 'outside'], |
124 | | - ], |
125 | | - 'no_spaces_inside_parenthesis' => true, |
126 | | - 'no_superfluous_phpdoc_tags' => [ |
127 | | - 'allow_mixed' => true, |
128 | | - 'allow_unused_params' => true, |
129 | | - ], |
130 | | - 'no_trailing_comma_in_singleline' => true, |
131 | | - 'no_trailing_whitespace' => true, |
132 | | - 'no_trailing_whitespace_in_comment' => true, |
133 | | - 'no_unneeded_control_parentheses' => [ |
134 | | - 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'], |
| 76 | + 'single_line_comment_style' => [ |
| 77 | + 'comment_types' => [ |
| 78 | + ], |
135 | 79 | ], |
136 | | - 'no_unneeded_curly_braces' => true, |
137 | | - 'no_unset_cast' => true, |
| 80 | + 'no_useless_else' => true, |
138 | 81 | 'no_unused_imports' => true, |
139 | | - 'no_unreachable_default_argument_value' => true, |
140 | | - 'no_useless_return' => true, |
141 | | - 'no_whitespace_before_comma_in_array' => true, |
142 | | - 'no_whitespace_in_blank_line' => true, |
143 | | - 'normalize_index_brace' => true, |
144 | 82 | 'not_operator_with_successor_space' => true, |
145 | | - 'nullable_type_declaration' => true, |
146 | | - 'nullable_type_declaration_for_default_null_value' => [ |
147 | | - 'use_nullable_type_declaration' => false, |
148 | | - ], |
149 | | - 'object_operator_without_whitespace' => true, |
150 | | - 'ordered_imports' => ['sort_algorithm' => 'alpha'], |
151 | | - 'psr_autoloading' => false, |
152 | | - 'phpdoc_indent' => true, |
153 | | - 'phpdoc_inline_tag_normalizer' => true, |
154 | | - 'phpdoc_no_access' => true, |
155 | | - 'phpdoc_no_package' => true, |
156 | | - 'phpdoc_no_useless_inheritdoc' => true, |
157 | | - 'phpdoc_order' => [ |
158 | | - 'order' => ['param', 'return', 'throws'], |
159 | | - ], |
160 | | - 'phpdoc_scalar' => true, |
161 | | - 'phpdoc_separation' => [ |
162 | | - 'groups' => [ |
163 | | - ['deprecated', 'link', 'see', 'since'], |
164 | | - ['author', 'copyright', 'license'], |
165 | | - ['category', 'package', 'subpackage'], |
166 | | - ['property', 'property-read', 'property-write'], |
167 | | - ['param', 'return'], |
168 | | - ], |
169 | | - ], |
170 | | - 'phpdoc_single_line_var_spacing' => true, |
171 | | - 'phpdoc_summary' => false, |
172 | | - 'phpdoc_to_comment' => false, |
173 | | - 'phpdoc_tag_type' => [ |
174 | | - 'tags' => [ |
175 | | - 'inheritdoc' => 'inline', |
176 | | - ], |
177 | | - ], |
178 | | - 'phpdoc_trim' => true, |
179 | | - 'phpdoc_types' => true, |
180 | | - 'phpdoc_var_without_name' => true, |
181 | | - 'return_type_declaration' => ['space_before' => 'none'], |
182 | | - 'self_accessor' => false, |
183 | | - 'self_static_accessor' => true, |
184 | | - 'short_scalar_cast' => true, |
185 | | - 'simplified_null_return' => false, |
186 | | - 'single_blank_line_at_eof' => true, |
187 | | - 'single_class_element_per_statement' => [ |
188 | | - 'elements' => ['const', 'property'], |
189 | | - ], |
190 | | - 'single_import_per_statement' => true, |
191 | | - 'single_line_after_imports' => true, |
192 | | - 'single_line_comment_style' => [ |
193 | | - 'comment_types' => ['hash'], |
194 | | - ], |
| 83 | + // 全局命名空间导入 |
| 84 | + 'global_namespace_import' => true, |
| 85 | + 'not_operator_with_space' => false, |
| 86 | + 'ordered_class_elements' => true, |
| 87 | + 'php_unit_strict' => false, |
| 88 | + 'phpdoc_separation' => false, |
195 | 89 | 'single_quote' => true, |
196 | | - 'single_space_around_construct' => true, |
197 | | - 'space_after_semicolon' => true, |
198 | 90 | 'standardize_not_equals' => true, |
199 | | - 'statement_indentation' => true, |
200 | | - 'switch_case_semicolon_to_colon' => true, |
201 | | - 'switch_case_space' => true, |
202 | | - 'ternary_operator_spaces' => true, |
203 | | - 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
204 | | - 'trim_array_spaces' => true, |
205 | | - 'type_declaration_spaces' => true, |
206 | | - 'types_spaces' => true, |
207 | | - 'unary_operator_spaces' => true, |
208 | | - 'visibility_required' => [ |
209 | | - 'elements' => ['method', 'property'], |
210 | | - ], |
211 | | - 'whitespace_after_comma_in_array' => true, |
212 | | - ])->setFinder( |
213 | | - PhpCsFixer\Finder::create() |
| 91 | + 'multiline_comment_opening_closing' => true, |
| 92 | + ]) |
| 93 | + ->setFinder( |
| 94 | + Finder::create() |
| 95 | + ->exclude('bin') |
214 | 96 | ->exclude('public') |
215 | 97 | ->exclude('runtime') |
216 | 98 | ->exclude('vendor') |
| 99 | + ->exclude('database/migrations') |
| 100 | + ->exclude('database/seeders') |
217 | 101 | ->in(__DIR__) |
218 | | - ); |
| 102 | + ) |
| 103 | + ->setUsingCache(true) |
| 104 | + ->setCacheFile(__DIR__ . '/.php-cs-fixer.cache'); |
0 commit comments