|
1 | 1 | <?php |
2 | 2 |
|
3 | | -// Thanks to https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200#gistcomment-3755709 |
4 | | - |
5 | | -use PhpCsFixer\Config; |
6 | | -use PhpCsFixer\Finder; |
7 | | - |
8 | | -$rules = [ |
9 | | - 'array_syntax' => [ |
10 | | - 'syntax' => 'short', |
11 | | - ], |
12 | | - 'binary_operator_spaces' => [ |
13 | | - 'default' => 'single_space', |
14 | | - 'operators' => [ |
15 | | - '=>' => null, |
16 | | - ], |
17 | | - ], |
18 | | - 'blank_line_after_namespace' => true, |
19 | | - 'blank_line_after_opening_tag' => true, |
20 | | - 'blank_line_before_statement' => [ |
21 | | - 'statements' => [ |
22 | | - 'return', |
23 | | - ], |
24 | | - ], |
25 | | - 'braces' => true, |
26 | | - 'cast_spaces' => true, |
27 | | - 'class_attributes_separation' => [ |
28 | | - 'elements' => [ |
29 | | - 'const' => 'one', |
30 | | - 'method' => 'one', |
31 | | - 'property' => 'one', |
32 | | - 'trait_import' => 'none', |
33 | | - ], |
34 | | - ], |
35 | | - 'class_definition' => [ |
36 | | - 'multi_line_extends_each_single_line' => true, |
37 | | - 'single_item_single_line' => true, |
38 | | - 'single_line' => true, |
39 | | - ], |
40 | | - 'concat_space' => [ |
41 | | - 'spacing' => 'none', |
42 | | - ], |
43 | | - 'constant_case' => [ |
44 | | - 'case' => 'lower', |
45 | | - ], |
46 | | - 'declare_equal_normalize' => true, |
47 | | - 'elseif' => true, |
48 | | - 'encoding' => true, |
49 | | - 'full_opening_tag' => true, |
50 | | - 'fully_qualified_strict_types' => true, |
51 | | - 'function_declaration' => true, |
52 | | - 'function_typehint_space' => true, |
53 | | - 'general_phpdoc_tag_rename' => true, |
54 | | - 'heredoc_to_nowdoc' => true, |
55 | | - 'include' => true, |
56 | | - 'increment_style' => [ |
57 | | - 'style' => 'post', |
58 | | - ], |
59 | | - 'indentation_type' => true, |
60 | | - 'line_ending' => true, |
61 | | - 'linebreak_after_opening_tag' => true, |
62 | | - 'lowercase_cast' => true, |
63 | | - 'lowercase_keywords' => true, |
64 | | - 'lowercase_static_reference' => true, |
65 | | - 'magic_constant_casing' => true, |
66 | | - 'magic_method_casing' => true, |
67 | | - 'method_argument_space' => true, |
68 | | - 'multiline_whitespace_before_semicolons' => [ |
69 | | - 'strategy' => 'no_multi_line', |
70 | | - ], |
71 | | - 'native_function_casing' => true, |
72 | | - 'no_alias_functions' => true, |
73 | | - 'no_blank_lines_after_class_opening' => true, |
74 | | - 'no_blank_lines_after_phpdoc' => true, |
75 | | - 'no_closing_tag' => true, |
76 | | - 'no_empty_phpdoc' => true, |
77 | | - 'no_empty_statement' => true, |
78 | | - 'no_extra_blank_lines' => [ |
79 | | - 'tokens' => [ |
80 | | - 'extra', |
81 | | - 'throw', |
82 | | - 'use', |
83 | | - ], |
84 | | - ], |
85 | | - 'no_leading_import_slash' => true, |
86 | | - 'no_leading_namespace_whitespace' => true, |
87 | | - 'no_mixed_echo_print' => [ |
88 | | - 'use' => 'echo', |
89 | | - ], |
90 | | - 'no_multiline_whitespace_around_double_arrow' => true, |
91 | | - 'no_short_bool_cast' => true, |
92 | | - 'no_singleline_whitespace_before_semicolons' => true, |
93 | | - 'no_spaces_after_function_name' => true, |
94 | | - 'no_spaces_around_offset' => [ |
95 | | - 'positions' => [ |
96 | | - 'inside', |
97 | | - 'outside', |
98 | | - ], |
99 | | - ], |
100 | | - 'no_spaces_inside_parenthesis' => true, |
101 | | - 'no_trailing_comma_in_list_call' => true, |
102 | | - 'no_trailing_comma_in_singleline_array' => true, |
103 | | - 'no_trailing_whitespace' => true, |
104 | | - 'no_trailing_whitespace_in_comment' => true, |
105 | | - 'no_unneeded_control_parentheses' => [ |
106 | | - 'statements' => [ |
107 | | - 'break', |
108 | | - 'clone', |
109 | | - 'continue', |
110 | | - 'echo_print', |
111 | | - 'return', |
112 | | - 'switch_case', |
113 | | - 'yield', |
114 | | - ], |
115 | | - ], |
116 | | - 'no_unreachable_default_argument_value' => true, |
117 | | - 'no_unused_imports' => true, |
118 | | - 'no_useless_return' => true, |
119 | | - 'no_whitespace_before_comma_in_array' => true, |
120 | | - 'no_whitespace_in_blank_line' => true, |
121 | | - 'normalize_index_brace' => true, |
122 | | - 'not_operator_with_successor_space' => true, |
123 | | - 'object_operator_without_whitespace' => true, |
124 | | - 'ordered_imports' => [ |
125 | | - 'sort_algorithm' => 'alpha', |
126 | | - ], |
127 | | - 'phpdoc_indent' => true, |
128 | | - 'phpdoc_inline_tag_normalizer' => true, |
129 | | - 'phpdoc_no_access' => true, |
130 | | - 'phpdoc_no_package' => true, |
131 | | - 'phpdoc_no_useless_inheritdoc' => true, |
132 | | - 'phpdoc_scalar' => true, |
133 | | - 'phpdoc_single_line_var_spacing' => true, |
134 | | - 'phpdoc_summary' => true, |
135 | | - 'phpdoc_tag_type' => true, |
136 | | - 'phpdoc_to_comment' => true, |
137 | | - 'phpdoc_trim' => true, |
138 | | - 'phpdoc_types' => true, |
139 | | - 'phpdoc_var_without_name' => true, |
140 | | - 'psr_autoloading' => true, |
141 | | - 'self_accessor' => true, |
142 | | - 'short_scalar_cast' => true, |
143 | | - 'simplified_null_return' => false, |
144 | | - 'single_blank_line_at_eof' => true, |
145 | | - 'single_blank_line_before_namespace' => true, |
146 | | - 'single_import_per_statement' => true, |
147 | | - 'single_line_after_imports' => true, |
148 | | - 'single_line_comment_style' => [ |
149 | | - 'comment_types' => [ |
150 | | - 'hash', |
151 | | - ], |
152 | | - ], |
153 | | - 'single_quote' => true, |
154 | | - 'space_after_semicolon' => true, |
155 | | - 'standardize_not_equals' => true, |
156 | | - 'switch_case_semicolon_to_colon' => true, |
157 | | - 'switch_case_space' => true, |
158 | | - 'ternary_operator_spaces' => true, |
159 | | - 'trailing_comma_in_multiline' => [ |
160 | | - 'elements' => [ |
161 | | - 'arrays', |
162 | | - ], |
163 | | - ], |
164 | | - 'trim_array_spaces' => true, |
165 | | - 'unary_operator_spaces' => true, |
166 | | - 'visibility_required' => [ |
167 | | - 'elements' => [ |
168 | | - 'property', |
169 | | - 'method', |
170 | | - 'const', |
171 | | - ], |
172 | | - ], |
173 | | - 'whitespace_after_comma_in_array' => true, |
174 | | -]; |
175 | | - |
176 | | -$finder = Finder::create() |
| 3 | +$finder = Symfony\Component\Finder\Finder::create() |
177 | 4 | ->in([ |
178 | | - __DIR__.'/config', |
179 | | - __DIR__.'/src', |
180 | | - __DIR__.'/tests', |
| 5 | + __DIR__ . '/src', |
| 6 | + __DIR__ . '/tests', |
181 | 7 | ]) |
182 | 8 | ->name('*.php') |
183 | | - ->notName('*.blade.php') |
184 | 9 | ->ignoreDotFiles(true) |
185 | 10 | ->ignoreVCS(true); |
186 | 11 |
|
187 | | -return (new Config()) |
188 | | - ->setFinder($finder) |
189 | | - ->setRules($rules) |
190 | | - ->setRiskyAllowed(true) |
191 | | - ->setUsingCache(true); |
| 12 | +return (new PhpCsFixer\Config()) |
| 13 | + ->setRules([ |
| 14 | + '@PSR2' => true, |
| 15 | + 'array_syntax' => ['syntax' => 'short'], |
| 16 | + 'ordered_imports' => ['sort_algorithm' => 'alpha'], |
| 17 | + 'no_unused_imports' => true, |
| 18 | + 'not_operator_with_successor_space' => true, |
| 19 | + 'trailing_comma_in_multiline' => true, |
| 20 | + 'phpdoc_scalar' => true, |
| 21 | + 'unary_operator_spaces' => true, |
| 22 | + 'binary_operator_spaces' => true, |
| 23 | + 'blank_line_before_statement' => [ |
| 24 | + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], |
| 25 | + ], |
| 26 | + 'phpdoc_single_line_var_spacing' => true, |
| 27 | + 'phpdoc_var_without_name' => true, |
| 28 | + 'class_attributes_separation' => [ |
| 29 | + 'elements' => [ |
| 30 | + 'method' => 'one', |
| 31 | + ], |
| 32 | + ], |
| 33 | + 'method_argument_space' => [ |
| 34 | + 'on_multiline' => 'ensure_fully_multiline', |
| 35 | + 'keep_multiple_spaces_after_comma' => true, |
| 36 | + ], |
| 37 | + 'single_trait_insert_per_statement' => true, |
| 38 | + ]) |
| 39 | + ->setFinder($finder); |
0 commit comments