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