Skip to content

Commit 4a7c5a1

Browse files
committed
chore: Lint + fix phpstan errors
1 parent f856132 commit 4a7c5a1

31 files changed

Lines changed: 932 additions & 579 deletions

.php-cs-fixer.dist.php

Lines changed: 342 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,348 @@
88
$config = new PhpCsFixer\Config;
99
$config->setFinder($finder)
1010
->setUnsupportedPhpVersionAllowed(true)
11-
->setRiskyAllowed(true);
11+
->setRiskyAllowed(true)
12+
->setRules([
13+
'align_multiline_comment' => true,
14+
'array_indentation' => true,
15+
'array_push' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'attribute_empty_parentheses' => [
18+
'use_parentheses' => false,
19+
],
20+
'backtick_to_shell_exec' => true,
21+
'binary_operator_spaces' => [
22+
'operators' => [
23+
'*=' => 'align_single_space_minimal',
24+
'+=' => 'align_single_space_minimal',
25+
'-=' => 'align_single_space_minimal',
26+
'/=' => 'align_single_space_minimal',
27+
'=' => 'align_single_space_minimal',
28+
'=>' => 'align_single_space_minimal',
29+
],
30+
],
31+
'blank_line_after_namespace' => true,
32+
'blank_line_before_statement' => [
33+
'statements' => [
34+
'break',
35+
'case',
36+
'continue',
37+
'declare',
38+
'default',
39+
'do',
40+
'exit',
41+
'for',
42+
'foreach',
43+
'goto',
44+
'if',
45+
'include',
46+
'include_once',
47+
'phpdoc',
48+
'require',
49+
'require_once',
50+
'return',
51+
'switch',
52+
'throw',
53+
'try',
54+
'while',
55+
'yield',
56+
'yield_from',
57+
],
58+
],
59+
'blank_lines_before_namespace' => [
60+
'max_line_breaks' => 1,
61+
'min_line_breaks' => 0,
62+
],
63+
'braces_position' => [
64+
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
65+
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
66+
],
67+
'cast_spaces' => true,
68+
'class_attributes_separation' => [
69+
'elements' => [
70+
'const' => 'none',
71+
'method' => 'one',
72+
'property' => 'only_if_meta'
73+
]
74+
],
75+
'class_definition' => true,
76+
'clean_namespace' => true,
77+
'combine_consecutive_issets' => true,
78+
'combine_consecutive_unsets' => true,
79+
'combine_nested_dirname' => true,
80+
'compact_nullable_type_declaration' => true,
81+
'concat_space' => ['spacing' => 'one'],
82+
'constant_case' => true,
83+
'control_structure_braces' => true,
84+
'control_structure_continuation_position' => true,
85+
'declare_equal_normalize' => ['space' => 'none'],
86+
'declare_parentheses' => true,
87+
'declare_strict_types' => true,
88+
'dir_constant' => true,
89+
'echo_tag_syntax' => true,
90+
'elseif' => true,
91+
'encoding' => true,
92+
'ereg_to_preg' => true,
93+
'explicit_indirect_variable' => true,
94+
'explicit_string_variable' => true,
95+
'fopen_flag_order' => true,
96+
'full_opening_tag' => true,
97+
'fully_qualified_strict_types' => ['import_symbols' => true],
98+
'function_declaration' => true,
99+
'function_to_constant' => true,
100+
'get_class_to_class_keyword' => true,
101+
'global_namespace_import' => [
102+
'import_classes' => true,
103+
'import_constants' => true,
104+
'import_functions' => true,
105+
],
106+
'heredoc_to_nowdoc' => true,
107+
'implode_call' => true,
108+
'include' => true,
109+
'increment_style' => [
110+
'style' => 'post',
111+
],
112+
'indentation_type' => true,
113+
'integer_literal_case' => true,
114+
'is_null' => true,
115+
'lambda_not_used_import' => true,
116+
'line_ending' => true,
117+
'list_syntax' => ['syntax' => 'short'],
118+
'logical_operators' => true,
119+
'lowercase_cast' => true,
120+
'lowercase_keywords' => true,
121+
'lowercase_static_reference' => true,
122+
'magic_constant_casing' => true,
123+
'magic_method_casing' => true,
124+
'method_argument_space' => [
125+
'on_multiline' => 'ensure_fully_multiline',
126+
],
127+
'method_chaining_indentation' => true,
128+
'modernize_strpos' => true,
129+
'modernize_types_casting' => true,
130+
'multiline_comment_opening_closing' => true,
131+
'multiline_whitespace_before_semicolons' => true,
132+
'native_constant_invocation' => true,
133+
'native_function_casing' => false,
134+
'native_function_invocation' => [
135+
'include' => [
136+
'@internal',
137+
],
138+
],
139+
'native_type_declaration_casing' => true,
140+
'new_with_parentheses' => [
141+
'anonymous_class' => false,
142+
'named_class' => false,
143+
],
144+
'no_alias_functions' => true,
145+
'no_alias_language_construct_call' => true,
146+
'no_alternative_syntax' => true,
147+
'no_binary_string' => true,
148+
'no_blank_lines_after_class_opening' => true,
149+
'no_blank_lines_after_phpdoc' => true,
150+
'no_break_comment' => true,
151+
'no_closing_tag' => true,
152+
'no_empty_comment' => true,
153+
'no_empty_phpdoc' => true,
154+
'no_empty_statement' => true,
155+
'no_extra_blank_lines' => [
156+
'tokens' => [
157+
'attribute',
158+
'break',
159+
'case',
160+
'continue',
161+
'curly_brace_block',
162+
'default',
163+
'extra',
164+
'parenthesis_brace_block',
165+
'return',
166+
'square_brace_block',
167+
'switch',
168+
'throw',
169+
'use',
170+
],
171+
],
172+
'no_homoglyph_names' => true,
173+
'no_leading_import_slash' => true,
174+
'no_leading_namespace_whitespace' => true,
175+
'no_mixed_echo_print' => ['use' => 'print'],
176+
'no_multiline_whitespace_around_double_arrow' => true,
177+
'no_multiple_statements_per_line' => true,
178+
'no_null_property_initialization' => true,
179+
'no_php4_constructor' => true,
180+
'no_short_bool_cast' => true,
181+
'no_singleline_whitespace_before_semicolons' => true,
182+
'no_space_around_double_colon' => true,
183+
'no_spaces_after_function_name' => true,
184+
'no_spaces_around_offset' => true,
185+
'no_superfluous_elseif' => true,
186+
'no_superfluous_phpdoc_tags' => [
187+
'allow_mixed' => true,
188+
],
189+
'no_trailing_comma_in_singleline' => true,
190+
'no_trailing_whitespace' => true,
191+
'no_trailing_whitespace_in_comment' => true,
192+
'no_trailing_whitespace_in_string' => true,
193+
'no_unneeded_braces' => true,
194+
'no_unneeded_control_parentheses' => true,
195+
'no_unneeded_final_method' => true,
196+
'no_unneeded_import_alias' => true,
197+
'no_unreachable_default_argument_value' => true,
198+
'no_unset_cast' => true,
199+
'no_unset_on_property' => true,
200+
'no_unused_imports' => true,
201+
'no_useless_concat_operator' => true,
202+
'no_useless_else' => true,
203+
'no_useless_nullsafe_operator' => true,
204+
'no_useless_return' => true,
205+
'no_useless_sprintf' => true,
206+
'no_whitespace_before_comma_in_array' => true,
207+
'no_whitespace_in_blank_line' => true,
208+
'non_printable_character' => true,
209+
'normalize_index_brace' => true,
210+
'nullable_type_declaration_for_default_null_value' => true,
211+
'object_operator_without_whitespace' => true,
212+
'octal_notation' => true,
213+
'operator_linebreak' => [
214+
'only_booleans' => true,
215+
'position' => 'end',
216+
],
217+
'ordered_class_elements' => [
218+
'order' => [
219+
'use_trait',
220+
'constant_public',
221+
'constant_protected',
222+
'constant_private',
223+
'property_public_static',
224+
'property_protected_static',
225+
'property_private_static',
226+
'property_public',
227+
'property_protected',
228+
'property_private',
229+
'method_public_static',
230+
'construct',
231+
'destruct',
232+
'magic',
233+
'phpunit',
234+
'method_public',
235+
'method_protected',
236+
'method_private',
237+
'method_protected_static',
238+
'method_private_static',
239+
],
240+
],
241+
'ordered_imports' => [
242+
'imports_order' => [
243+
'const',
244+
'function',
245+
'class',
246+
]
247+
],
248+
'ordered_interfaces' => [
249+
'direction' => 'ascend',
250+
'order' => 'alpha',
251+
],
252+
'ordered_traits' => true,
253+
'ordered_types' => true,
254+
'php_unit_set_up_tear_down_visibility' => true,
255+
'php_unit_test_case_static_method_calls' => [
256+
'call_type' => 'this',
257+
],
258+
'phpdoc_add_missing_param_annotation' => false,
259+
'phpdoc_align' => true,
260+
'phpdoc_annotation_without_dot' => true,
261+
'phpdoc_indent' => true,
262+
'phpdoc_inline_tag_normalizer' => true,
263+
'phpdoc_no_access' => true,
264+
'phpdoc_no_alias_tag' => true,
265+
'phpdoc_no_empty_return' => true,
266+
'phpdoc_no_package' => true,
267+
'phpdoc_no_useless_inheritdoc' => true,
268+
'phpdoc_order' => true,
269+
'phpdoc_order_by_value' => [
270+
'annotations' => [
271+
'covers',
272+
'dataProvider',
273+
'throws',
274+
'uses',
275+
],
276+
],
277+
'phpdoc_param_order' => true,
278+
'phpdoc_return_self_reference' => true,
279+
'phpdoc_scalar' => true,
280+
'phpdoc_separation' => true,
281+
'phpdoc_single_line_var_spacing' => true,
282+
'phpdoc_summary' => true,
283+
'phpdoc_tag_casing' => true,
284+
'phpdoc_tag_type' => true,
285+
'phpdoc_to_comment' => false,
286+
'phpdoc_trim' => true,
287+
'phpdoc_trim_consecutive_blank_line_separation' => true,
288+
'phpdoc_types' => ['groups' => ['simple', 'meta']],
289+
'phpdoc_types_order' => true,
290+
'phpdoc_var_annotation_correct_order' => true,
291+
'phpdoc_var_without_name' => true,
292+
'pow_to_exponentiation' => true,
293+
'protected_to_private' => true,
294+
'return_assignment' => true,
295+
'return_type_declaration' => ['space_before' => 'none'],
296+
'self_accessor' => true,
297+
'self_static_accessor' => true,
298+
'semicolon_after_instruction' => true,
299+
'set_type_to_cast' => true,
300+
'short_scalar_cast' => true,
301+
'simple_to_complex_string_variable' => true,
302+
'simplified_null_return' => false,
303+
'single_blank_line_at_eof' => true,
304+
'single_class_element_per_statement' => true,
305+
'single_import_per_statement' => true,
306+
'single_line_after_imports' => true,
307+
'single_line_comment_spacing' => true,
308+
'single_quote' => true,
309+
'single_space_around_construct' => true,
310+
'single_trait_insert_per_statement' => true,
311+
'space_after_semicolon' => true,
312+
'spaces_inside_parentheses' => [
313+
'space' => 'none',
314+
],
315+
'standardize_increment' => true,
316+
'standardize_not_equals' => true,
317+
'statement_indentation' => true,
318+
'static_lambda' => true,
319+
'strict_param' => true,
320+
'string_length_to_empty'=> true,
321+
'string_line_ending' => true,
322+
'switch_case_semicolon_to_colon' => true,
323+
'switch_case_space' => true,
324+
'switch_continue_to_break' => true,
325+
'ternary_operator_spaces' => true,
326+
'ternary_to_elvis_operator' => true,
327+
'ternary_to_null_coalescing' => true,
328+
'trailing_comma_in_multiline' => [
329+
'elements' => [
330+
'arguments',
331+
'arrays',
332+
'match',
333+
]
334+
],
335+
'trim_array_spaces' => true,
336+
'type_declaration_spaces' => [
337+
'elements' => [
338+
'function',
339+
],
340+
],
341+
'types_spaces' => true,
342+
'unary_operator_spaces' => true,
343+
'visibility_required' => [
344+
'elements' => [
345+
'const',
346+
'method',
347+
'property',
348+
],
349+
],
350+
'void_return' => true,
351+
'whitespace_after_comma_in_array' => true,
352+
]);
12353

13354
$config->setParallelConfig(\PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());
14355

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,11 @@
5151
"allow-plugins": {
5252
"php-http/discovery": true
5353
}
54+
},
55+
"scripts": {
56+
"test": "./tools/phpunit",
57+
"phpstan": "./tools/phpstan analyse --memory-limit=-1",
58+
"lint": "./tools/php-cs-fixer check",
59+
"lint-fix": "./tools/php-cs-fixer fix"
5460
}
5561
}

0 commit comments

Comments
 (0)