Failed Conditions
Pull Request — master (#4439)
by Owen
17:04 queued 03:26
created

.php-cs-fixer.dist.php (1 issue)

Severity
1
<?php
2
3
$finder = PhpCsFixer\Finder::create()
4
    ->exclude('vendor', 'docs', '.git', '.github')
0 ignored issues
show
The call to Symfony\Component\Finder\Finder::exclude() has too many arguments starting with 'docs'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

4
    ->/** @scrutinizer ignore-call */ exclude('vendor', 'docs', '.git', '.github')

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
5
    ->notPath('src/PhpSpreadsheet/Writer/ZipStream3.php')
6
    ->in(__DIR__);
7
8
$config = new PhpCsFixer\Config();
9
$config
10
    ->setRiskyAllowed(true)
11
    ->setFinder($finder)
12
    ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect(null, 600))
13
    ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
14
    ->setRules([
15
        'align_multiline_comment' => true,
16
        'array_indentation' => true,
17
        'array_syntax' => ['syntax' => 'short'],
18
        'backtick_to_shell_exec' => true,
19
        'binary_operator_spaces' => true,
20
        'blank_line_after_namespace' => true,
21
        'blank_lines_before_namespace' => ['max_line_breaks' => 2, 'min_line_breaks' => 2], // we want 1 blank line before namespace
22
        'blank_line_after_opening_tag' => true,
23
        'blank_line_before_statement' => true,
24
        'cast_spaces' => true,
25
        'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
26
        'class_definition' => false, // phpcs disagree
27
        'combine_consecutive_issets' => true,
28
        'combine_consecutive_unsets' => true,
29
        'combine_nested_dirname' => true,
30
        'comment_to_phpdoc' => false, // interferes with annotations
31
        'compact_nullable_type_declaration' => true,
32
        'concat_space' => ['spacing' => 'one'],
33
        'constant_case' => true,
34
        'date_time_immutable' => false, // Break our unit tests
35
        'declare_equal_normalize' => true,
36
        'declare_strict_types' => false, // Too early to adopt strict types
37
        'dir_constant' => true,
38
        'doctrine_annotation_array_assignment' => true,
39
        'doctrine_annotation_braces' => true,
40
        'doctrine_annotation_indentation' => true,
41
        'doctrine_annotation_spaces' => true,
42
        'elseif' => true,
43
        'empty_loop_body' => true,
44
        'empty_loop_condition' => true,
45
        'encoding' => true,
46
        'ereg_to_preg' => true,
47
        'error_suppression' => false, // it breaks \PhpOffice\PhpSpreadsheet\Helper\Handler
48
        'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
49
        'explicit_string_variable' => false, // I feel it makes the code actually harder to read
50
        'final_class' => false, // We need non-final classes
51
        'final_internal_class' => true,
52
        'final_public_method_for_abstract_class' => false, // We need non-final methods
53
        'fopen_flag_order' => true,
54
        'fopen_flags' => true,
55
        'full_opening_tag' => true,
56
        'fully_qualified_strict_types' => true,
57
        'function_declaration' => true,
58
        'function_to_constant' => true,
59
        'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright']],
60
        'general_phpdoc_tag_rename' => true,
61
        'global_namespace_import' => true,
62
        'group_import' => false, // I feel it makes the code actually harder to read
63
        'header_comment' => false, // We don't use common header in all our files
64
        'heredoc_indentation' => true,
65
        'heredoc_to_nowdoc' => false, // Not sure about this one
66
        'implode_call' => true,
67
        'include' => true,
68
        'increment_style' => true,
69
        'indentation_type' => true,
70
        'integer_literal_case' => true,
71
        'is_null' => true,
72
        'lambda_not_used_import' => true,
73
        'line_ending' => true,
74
        'linebreak_after_opening_tag' => true,
75
        'list_syntax' => ['syntax' => 'short'],
76
        'logical_operators' => true,
77
        'lowercase_cast' => true,
78
        'lowercase_keywords' => true,
79
        'lowercase_static_reference' => true,
80
        'magic_constant_casing' => true,
81
        'magic_method_casing' => true,
82
        'mb_str_functions' => false, // No, too dangerous to change that
83
        'method_argument_space' => true,
84
        'method_chaining_indentation' => true,
85
        'modernize_strpos' => true,
86
        'modernize_types_casting' => true,
87
        'multiline_comment_opening_closing' => true,
88
        'multiline_whitespace_before_semicolons' => true,
89
        'native_constant_invocation' => false, // Micro optimization that look messy
90
        'native_function_casing' => true,
91
        'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
92
        'new_with_parentheses' => ['anonymous_class' => true, 'named_class' => true],
93
        'no_alias_functions' => true,
94
        'no_alias_language_construct_call' => true,
95
        'no_alternative_syntax' => true,
96
        'no_binary_string' => true,
97
        'no_blank_lines_after_class_opening' => true,
98
        'no_blank_lines_after_phpdoc' => true,
99
        'no_break_comment' => true,
100
        'no_closing_tag' => true,
101
        'no_empty_comment' => true,
102
        'no_empty_phpdoc' => true,
103
        'no_empty_statement' => true,
104
        'no_extra_blank_lines' => true,
105
        'no_homoglyph_names' => true,
106
        'no_leading_import_slash' => true,
107
        'no_leading_namespace_whitespace' => true,
108
        'no_mixed_echo_print' => true,
109
        'no_multiline_whitespace_around_double_arrow' => true,
110
        'no_null_property_initialization' => true,
111
        'no_php4_constructor' => true,
112
        'no_short_bool_cast' => true,
113
        'echo_tag_syntax' => ['format' => 'long'],
114
        'no_singleline_whitespace_before_semicolons' => true,
115
        'no_space_around_double_colon' => true,
116
        'no_spaces_after_function_name' => true,
117
        'no_spaces_around_offset' => true,
118
        'no_superfluous_elseif' => false, // Might be risky on a huge code base
119
        'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
120
        'no_trailing_comma_in_singleline' => ['elements' => ['arguments', 'array_destructuring', 'array', 'group_import']],
121
        'no_trailing_whitespace' => true,
122
        'no_trailing_whitespace_in_comment' => true,
123
        'no_trailing_whitespace_in_string' => false, // Too dangerous
124
        'no_unneeded_control_parentheses' => true,
125
        'no_unneeded_braces' => true,
126
        'no_unneeded_final_method' => true,
127
        'no_unreachable_default_argument_value' => true,
128
        'no_unset_cast' => true,
129
        'no_unset_on_property' => false,
130
        'no_unused_imports' => true,
131
        'no_useless_else' => true,
132
        'no_useless_return' => true,
133
        'no_useless_sprintf' => true,
134
        'no_whitespace_before_comma_in_array' => true,
135
        'no_whitespace_in_blank_line' => true,
136
        'non_printable_character' => true,
137
        'normalize_index_brace' => true,
138
        'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
139
        'not_operator_with_successor_space' => false, // idem
140
        'nullable_type_declaration_for_default_null_value' => true,
141
        'object_operator_without_whitespace' => true,
142
        'octal_notation' => true,
143
        'operator_linebreak' => true,
144
        'ordered_class_elements' => false, // We prefer to keep some freedom
145
        'ordered_imports' => true,
146
        'ordered_interfaces' => true,
147
        'ordered_traits' => true,
148
        'php_unit_attributes' => ['keep_annotations' => false],
149
        'php_unit_construct' => true,
150
        'php_unit_dedicate_assert' => true,
151
        'php_unit_dedicate_assert_internal_type' => true,
152
        'php_unit_expectation' => true,
153
        'php_unit_fqcn_annotation' => true,
154
        'php_unit_internal_class' => false, // Because tests are excluded from package
155
        'php_unit_method_casing' => true,
156
        'php_unit_mock' => true,
157
        'php_unit_mock_short_will_return' => true,
158
        'php_unit_namespaced' => true,
159
        'php_unit_no_expectation_annotation' => true,
160
        'phpdoc_order_by_value' => ['annotations' => ['covers']],
161
        'php_unit_set_up_tear_down_visibility' => true,
162
        'php_unit_size_class' => false, // That seems extra work to maintain for little benefits
163
        'php_unit_strict' => false, // We sometime actually need assertEquals
164
        'php_unit_test_annotation' => true,
165
        'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
166
        'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
167
        'phpdoc_add_missing_param_annotation' => false, // Don't add things that bring no value
168
        'phpdoc_align' => false, // Waste of time
169
        'phpdoc_annotation_without_dot' => true,
170
        'phpdoc_indent' => true,
171
        'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
172
        'phpdoc_no_access' => true,
173
        'phpdoc_no_alias_tag' => true,
174
        'phpdoc_no_empty_return' => true,
175
        'phpdoc_no_package' => true,
176
        'phpdoc_no_useless_inheritdoc' => true,
177
        'phpdoc_order' => true,
178
        'phpdoc_return_self_reference' => true,
179
        'phpdoc_scalar' => true,
180
        'phpdoc_separation' => true,
181
        'phpdoc_single_line_var_spacing' => true,
182
        'phpdoc_summary' => true,
183
        'phpdoc_tag_casing' => true,
184
        'phpdoc_tag_type' => true,
185
        'phpdoc_to_comment' => false, // interferes with annotations
186
        'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use
187
        'phpdoc_to_property_type' => false, // Because experimental, but interesting for one shot use
188
        'phpdoc_to_return_type' => false, // Because experimental, but interesting for one shot use
189
        'phpdoc_trim' => true,
190
        'phpdoc_trim_consecutive_blank_line_separation' => true,
191
        'phpdoc_types' => true,
192
        'phpdoc_types_order' => true,
193
        'phpdoc_var_annotation_correct_order' => true,
194
        'phpdoc_var_without_name' => true,
195
        'pow_to_exponentiation' => true,
196
        'protected_to_private' => true,
197
        'psr_autoloading' => true,
198
        'random_api_migration' => true,
199
        'return_assignment' => false, // Sometimes useful for clarity or debug
200
        'return_type_declaration' => true,
201
        'self_accessor' => true,
202
        'self_static_accessor' => true,
203
        'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
204
        'set_type_to_cast' => true,
205
        'short_scalar_cast' => true,
206
        'simple_to_complex_string_variable' => false, // Would differ from TypeScript without obvious advantages
207
        'simplified_if_return' => false, // Even if technically correct we prefer to be explicit
208
        'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
209
        'single_blank_line_at_eof' => true,
210
        'single_class_element_per_statement' => true,
211
        'single_import_per_statement' => true,
212
        'single_line_after_imports' => true,
213
        'single_line_comment_style' => true,
214
        'single_line_throw' => false, // I don't see any reason for having a special case for Exception
215
        'single_quote' => true,
216
        'single_trait_insert_per_statement' => true,
217
        'space_after_semicolon' => true,
218
        'spaces_inside_parentheses' => ['space' => 'none'],
219
        'standardize_increment' => true,
220
        'standardize_not_equals' => true,
221
        'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
222
        'strict_comparison' => false, // No, too dangerous to change that
223
        'string_implicit_backslashes' => ['single_quoted' => 'unescape', 'double_quoted' => 'escape', 'heredoc' => 'escape'], // was escape_implicit_backslashes
224
        'strict_param' => false, // No, too dangerous to change that
225
        'string_length_to_empty' => true,
226
        'string_line_ending' => true,
227
        'switch_case_semicolon_to_colon' => true,
228
        'switch_case_space' => true,
229
        'switch_continue_to_break' => true,
230
        'ternary_operator_spaces' => true,
231
        'ternary_to_elvis_operator' => true,
232
        'ternary_to_null_coalescing' => true,
233
        'trailing_comma_in_multiline' => true,
234
        'trim_array_spaces' => true,
235
        'type_declaration_spaces' => ['elements' => ['function', 'property']], // was function_typehint_space
236
        'types_spaces' => true,
237
        'unary_operator_spaces' => true,
238
        'use_arrow_functions' => true,
239
        'visibility_required' => ['elements' => ['property', 'method']], // not const
240
        'void_return' => true,
241
        'whitespace_after_comma_in_array' => true,
242
        'yoda_style' => false,
243
    ]);
244
245
return $config;
246