|
1 |
| -<?php |
2 |
| - |
| 1 | +<?php declare(strict_types=1); |
3 | 2 | /*
|
4 |
| - * Cypher DSL |
5 |
| - * Copyright (C) 2021 Wikibase Solutions |
6 |
| - * |
7 |
| - * This program is free software; you can redistribute it and/or |
8 |
| - * modify it under the terms of the GNU General Public License |
9 |
| - * as published by the Free Software Foundation; either version 2 |
10 |
| - * of the License, or (at your option) any later version. |
| 3 | + * This file is part of php-cypher-dsl. |
11 | 4 | *
|
12 |
| - * This program is distributed in the hope that it will be useful, |
13 |
| - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
| - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
| - * GNU General Public License for more details. |
| 5 | + * Copyright (C) Wikibase Solutions |
16 | 6 | *
|
17 |
| - * You should have received a copy of the GNU General Public License |
18 |
| - * along with this program; if not, write to the Free Software |
19 |
| - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
20 | 9 | */
|
21 |
| - |
22 | 10 | use PhpCsFixer\Config;
|
23 | 11 | use PhpCsFixer\Finder;
|
24 | 12 |
|
25 |
| -$finder = Finder::create() |
26 |
| - ->in(__DIR__) |
27 |
| - ->exclude([ |
28 |
| - '.github', |
29 |
| - 'vendor' |
30 |
| - ]) |
31 |
| - ->name('*php'); |
32 |
| - |
33 | 13 | $header = <<<'COPYRIGHT'
|
34 | 14 | This file is part of php-cypher-dsl.
|
35 | 15 |
|
36 |
| -Copyright (C) 2021- Wikibase Solutions |
| 16 | +Copyright (C) Wikibase Solutions |
37 | 17 |
|
38 | 18 | For the full copyright and license information, please view the LICENSE
|
39 | 19 | file that was distributed with this source code.
|
40 | 20 | COPYRIGHT;
|
41 | 21 |
|
42 |
| -return (new Config()) |
43 |
| - ->setRiskyAllowed(true) |
| 22 | +$finder = Finder::create() |
| 23 | + ->files() |
| 24 | + ->in(__DIR__ . '/src') |
| 25 | + ->in(__DIR__ . '/tests/Unit') |
| 26 | + ->in(__DIR__ . '/tests/Integration') |
| 27 | + ->name('*.php'); |
| 28 | + |
| 29 | +$config = new Config(); |
| 30 | +$config->setFinder($finder) |
| 31 | + ->setRiskyAllowed(true) |
44 | 32 | ->setRules([
|
45 |
| - '@PSR12' => true, |
46 | 33 | 'align_multiline_comment' => true,
|
47 | 34 | 'array_indentation' => true,
|
| 35 | + 'array_push' => true, |
| 36 | + 'backtick_to_shell_exec' => true, |
| 37 | + 'blank_line_after_namespace' => true, |
| 38 | + 'blank_line_after_opening_tag' => false, |
48 | 39 | 'blank_line_before_statement' => [
|
49 | 40 | 'statements' => [
|
50 | 41 | 'break',
|
51 | 42 | 'continue',
|
52 | 43 | 'declare',
|
| 44 | + 'default', |
53 | 45 | 'do',
|
| 46 | + 'exit', |
54 | 47 | 'for',
|
55 | 48 | 'foreach',
|
| 49 | + 'goto', |
56 | 50 | 'if',
|
57 | 51 | 'include',
|
58 | 52 | 'include_once',
|
|
66 | 60 | 'yield',
|
67 | 61 | ],
|
68 | 62 | ],
|
69 |
| - 'compact_nullable_typehint' => true, |
| 63 | + 'braces' => [ |
| 64 | + 'position_after_anonymous_constructs' => 'next', |
| 65 | + ], |
| 66 | + 'cast_spaces' => true, |
| 67 | + 'class_attributes_separation' => [ |
| 68 | + 'elements' => [ |
| 69 | + 'const' => 'one', |
| 70 | + 'method' => 'one', |
| 71 | + 'property' => 'only_if_meta', |
| 72 | + ], |
| 73 | + ], |
| 74 | + 'class_definition' => true, |
| 75 | + 'clean_namespace' => true, |
| 76 | + 'combine_consecutive_issets' => true, |
| 77 | + 'combine_consecutive_unsets' => true, |
| 78 | + 'combine_nested_dirname' => true, |
| 79 | + 'compact_nullable_typehint' => true, |
70 | 80 | 'concat_space' => ['spacing' => 'one'],
|
71 |
| - 'declare_strict_types' => true, |
72 |
| - 'declare_equal_normalize' => true, |
| 81 | + 'constant_case' => true, |
| 82 | + 'declare_equal_normalize' => ['space' => 'none'], |
| 83 | + 'declare_strict_types' => true, |
| 84 | + 'dir_constant' => true, |
| 85 | + 'echo_tag_syntax' => true, |
| 86 | + 'elseif' => true, |
| 87 | + 'encoding' => true, |
| 88 | + 'ereg_to_preg' => true, |
| 89 | + 'explicit_indirect_variable' => true, |
| 90 | + 'explicit_string_variable' => true, |
| 91 | + 'fopen_flag_order' => true, |
| 92 | + 'full_opening_tag' => true, |
73 | 93 | 'fully_qualified_strict_types' => true,
|
74 |
| - 'global_namespace_import' => [ |
75 |
| - 'import_classes' => true, |
76 |
| - 'import_constants' => false, |
77 |
| - 'import_functions' => false |
78 |
| - ], |
| 94 | + 'global_namespace_import' => [ |
| 95 | + 'import_classes' => true, |
| 96 | + 'import_constants' => false, |
| 97 | + 'import_functions' => false, |
| 98 | + ], |
79 | 99 | 'header_comment' => [
|
80 | 100 | 'header' => $header,
|
81 |
| - 'separate' => 'none' |
| 101 | + 'separate' => 'none', |
82 | 102 | ],
|
| 103 | + 'heredoc_to_nowdoc' => true, |
| 104 | + 'implode_call' => true, |
| 105 | + 'include' => true, |
| 106 | + 'indentation_type' => true, |
| 107 | + 'is_null' => true, |
| 108 | + 'lambda_not_used_import' => true, |
| 109 | + 'line_ending' => true, |
83 | 110 | 'list_syntax' => [
|
84 | 111 | 'syntax' => 'short',
|
85 | 112 | ],
|
86 |
| - 'logical_operators' => true, |
87 |
| - 'no_superfluous_phpdoc_tags' => true, |
88 |
| - 'no_unset_cast' => true, |
| 113 | + 'logical_operators' => true, |
| 114 | + 'lowercase_cast' => true, |
| 115 | + 'lowercase_keywords' => true, |
| 116 | + 'lowercase_static_reference' => true, |
| 117 | + 'magic_constant_casing' => true, |
| 118 | + 'magic_method_casing' => true, |
| 119 | + 'method_argument_space' => [ |
| 120 | + 'on_multiline' => 'ensure_fully_multiline', |
| 121 | + ], |
| 122 | + 'modernize_types_casting' => true, |
| 123 | + 'multiline_comment_opening_closing' => true, |
| 124 | + 'multiline_whitespace_before_semicolons' => true, |
| 125 | + 'native_constant_invocation' => false, |
| 126 | + 'native_function_casing' => false, |
| 127 | + 'native_function_invocation' => false, |
| 128 | + 'native_function_type_declaration_casing' => true, |
| 129 | + 'no_alias_functions' => true, |
| 130 | + 'no_alias_language_construct_call' => true, |
| 131 | + 'no_blank_lines_after_class_opening' => true, |
| 132 | + 'no_blank_lines_after_phpdoc' => true, |
| 133 | + 'no_blank_lines_before_namespace' => true, |
| 134 | + 'no_break_comment' => true, |
| 135 | + 'no_closing_tag' => true, |
| 136 | + 'no_empty_comment' => true, |
| 137 | + 'no_empty_phpdoc' => true, |
| 138 | + 'no_empty_statement' => true, |
| 139 | + 'no_extra_blank_lines' => true, |
| 140 | + 'no_homoglyph_names' => true, |
| 141 | + 'no_leading_import_slash' => true, |
| 142 | + 'no_leading_namespace_whitespace' => true, |
| 143 | + 'no_php4_constructor' => true, |
| 144 | + 'no_short_bool_cast' => true, |
| 145 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 146 | + 'no_spaces_after_function_name' => true, |
| 147 | + 'no_spaces_around_offset' => true, |
| 148 | + 'no_spaces_inside_parenthesis' => true, |
| 149 | + 'no_superfluous_elseif' => true, |
| 150 | + 'no_superfluous_phpdoc_tags' => [ |
| 151 | + 'allow_mixed' => true, |
| 152 | + ], |
| 153 | + 'no_trailing_comma_in_list_call' => true, |
| 154 | + 'no_trailing_comma_in_singleline_array' => true, |
| 155 | + 'no_trailing_whitespace' => true, |
| 156 | + 'no_trailing_whitespace_in_comment' => true, |
| 157 | + 'no_trailing_whitespace_in_string' => true, |
| 158 | + 'no_unneeded_control_parentheses' => true, |
| 159 | + 'no_unneeded_curly_braces' => true, |
| 160 | + 'no_unneeded_final_method' => true, |
| 161 | + 'no_unreachable_default_argument_value' => true, |
| 162 | + 'no_unset_cast' => true, |
| 163 | + 'no_unset_on_property' => true, |
89 | 164 | 'no_unused_imports' => true,
|
90 | 165 | 'no_useless_else' => true,
|
91 | 166 | 'no_useless_return' => true,
|
| 167 | + 'no_useless_sprintf' => true, |
| 168 | + 'no_whitespace_before_comma_in_array' => true, |
| 169 | + 'no_whitespace_in_blank_line' => true, |
92 | 170 | 'nullable_type_declaration_for_default_null_value' => true,
|
93 |
| - 'ordered_class_elements' => true, |
94 |
| - 'ordered_imports' => true, |
95 |
| - 'ordered_interfaces' => true, |
96 |
| - 'ordered_traits' => true, |
97 |
| - 'phpdoc_align' => [ |
98 |
| - 'align' => 'left', |
| 171 | + 'ordered_class_elements' => [ |
| 172 | + 'order' => [ |
| 173 | + 'use_trait', |
| 174 | + 'constant_public', |
| 175 | + 'constant_protected', |
| 176 | + 'constant_private', |
| 177 | + 'property_public_static', |
| 178 | + 'property_protected_static', |
| 179 | + 'property_private_static', |
| 180 | + 'property_public', |
| 181 | + 'property_protected', |
| 182 | + 'property_private', |
| 183 | + 'method_public_static', |
| 184 | + 'construct', |
| 185 | + 'destruct', |
| 186 | + 'magic', |
| 187 | + 'phpunit', |
| 188 | + 'method_public', |
| 189 | + 'method_protected', |
| 190 | + 'method_private', |
| 191 | + 'method_protected_static', |
| 192 | + 'method_private_static', |
| 193 | + ], |
99 | 194 | ],
|
100 |
| - 'phpdoc_scalar' => true, |
101 |
| - 'phpdoc_order_by_value' => [ |
102 |
| - 'annotations' => ['covers'], |
103 |
| - ], |
104 |
| - 'phpdoc_no_empty_return' => true, |
105 |
| - 'phpdoc_order' => true, |
106 |
| - 'php_unit_dedicate_assert' => true, |
107 |
| - 'php_unit_set_up_tear_down_visibility' => true, |
| 195 | + 'ordered_imports' => true, |
| 196 | + 'ordered_interfaces' => true, |
| 197 | + 'ordered_traits' => true, |
| 198 | + 'php_unit_dedicate_assert' => true, |
| 199 | + 'php_unit_set_up_tear_down_visibility' => true, |
108 | 200 | 'php_unit_method_casing' => [
|
109 | 201 | 'case' => 'camel_case',
|
110 | 202 | ],
|
111 |
| - 'php_unit_test_annotation' => [ |
112 |
| - 'style' => 'prefix', |
113 |
| - ], |
114 |
| - 'php_unit_test_case_static_method_calls' => [ |
115 |
| - 'call_type' => 'this', |
116 |
| - ], |
| 203 | + 'php_unit_test_annotation' => [ |
| 204 | + 'style' => 'prefix', |
| 205 | + ], |
| 206 | + 'php_unit_test_case_static_method_calls' => [ |
| 207 | + 'call_type' => 'this', |
| 208 | + ], |
| 209 | + 'phpdoc_align' => true, |
| 210 | + 'phpdoc_annotation_without_dot' => true, |
| 211 | + 'phpdoc_indent' => true, |
| 212 | + 'phpdoc_inline_tag_normalizer' => true, |
| 213 | + 'phpdoc_no_access' => true, |
| 214 | + 'phpdoc_no_alias_tag' => true, |
| 215 | + 'phpdoc_no_empty_return' => true, |
| 216 | + 'phpdoc_no_package' => true, |
| 217 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 218 | + 'phpdoc_order' => true, |
| 219 | + 'phpdoc_order_by_value' => [ |
| 220 | + 'annotations' => [ |
| 221 | + 'covers', |
| 222 | + 'dataProvider', |
| 223 | + 'throws', |
| 224 | + 'uses', |
| 225 | + ], |
| 226 | + ], |
| 227 | + 'phpdoc_return_self_reference' => true, |
| 228 | + 'phpdoc_scalar' => true, |
| 229 | + 'phpdoc_separation' => true, |
| 230 | + 'phpdoc_single_line_var_spacing' => true, |
| 231 | + 'phpdoc_summary' => true, |
| 232 | + 'phpdoc_tag_casing' => true, |
| 233 | + 'phpdoc_tag_type' => true, |
| 234 | + 'phpdoc_to_comment' => true, |
| 235 | + 'phpdoc_trim' => true, |
| 236 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 237 | + 'phpdoc_types' => ['groups' => ['simple', 'meta']], |
| 238 | + 'phpdoc_types_order' => true, |
| 239 | + 'phpdoc_var_annotation_correct_order' => true, |
| 240 | + 'phpdoc_var_without_name' => true, |
| 241 | + 'pow_to_exponentiation' => true, |
| 242 | + 'protected_to_private' => true, |
117 | 243 | 'return_assignment' => true,
|
| 244 | + 'self_accessor' => true, |
118 | 245 | 'self_static_accessor' => true,
|
119 |
| - 'single_line_throw' => true, |
| 246 | + 'semicolon_after_instruction' => true, |
| 247 | + 'set_type_to_cast' => true, |
| 248 | + 'short_scalar_cast' => true, |
| 249 | + 'simple_to_complex_string_variable' => true, |
120 | 250 | 'simplified_if_return' => true,
|
121 |
| - 'static_lambda' => true, |
122 |
| - 'strict_comparison' => true, |
123 |
| - 'strict_param' => true, |
| 251 | + 'single_blank_line_at_eof' => true, |
| 252 | + 'single_class_element_per_statement' => true, |
| 253 | + 'single_import_per_statement' => true, |
| 254 | + 'single_line_after_imports' => true, |
| 255 | + 'single_line_throw' => true, |
| 256 | + 'space_after_semicolon' => true, |
| 257 | + 'standardize_increment' => true, |
| 258 | + 'standardize_not_equals' => true, |
| 259 | + 'static_lambda' => true, |
| 260 | + 'strict_comparison' => true, |
| 261 | + 'strict_param' => true, |
| 262 | + 'string_line_ending' => true, |
| 263 | + 'switch_case_semicolon_to_colon' => true, |
| 264 | + 'switch_case_space' => true, |
| 265 | + 'switch_continue_to_break' => true, |
| 266 | + 'ternary_operator_spaces' => true, |
| 267 | + 'ternary_to_elvis_operator' => true, |
| 268 | + 'ternary_to_null_coalescing' => true, |
124 | 269 | 'trailing_comma_in_multiline' => true,
|
125 |
| - 'yoda_style' => [ |
126 |
| - 'equal' => false, |
127 |
| - 'identical' => false, |
128 |
| - 'less_and_greater' => false, |
129 |
| - ] |
130 |
| - ]) |
131 |
| - ->setFinder($finder); |
| 270 | + 'trim_array_spaces' => true, |
| 271 | + 'unary_operator_spaces' => true, |
| 272 | + 'visibility_required' => [ |
| 273 | + 'elements' => [ |
| 274 | + 'const', |
| 275 | + 'method', |
| 276 | + 'property', |
| 277 | + ], |
| 278 | + ], |
| 279 | + 'void_return' => true, |
| 280 | + 'whitespace_after_comma_in_array' => true, |
| 281 | + 'yoda_style' => [ |
| 282 | + 'equal' => false, |
| 283 | + 'identical' => false, |
| 284 | + 'less_and_greater' => false, |
| 285 | + ], |
| 286 | + ]); |
| 287 | + |
| 288 | +return $config; |
0 commit comments