Skip to content

Commit 99075bf

Browse files
committed
Update php-cs-fixer configuration #11599
1 parent 639f05a commit 99075bf

File tree

3 files changed

+73
-26
lines changed

3 files changed

+73
-26
lines changed

.php-cs-fixer.dist.php

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,35 @@
1616
'array_push' => true,
1717
'array_syntax' => ['syntax' => 'short'],
1818
'assign_null_coalescing_to_coalesce_equal' => true,
19+
'attribute_empty_parentheses' => true,
1920
'backtick_to_shell_exec' => true,
2021
'binary_operator_spaces' => true,
2122
'blank_line_after_namespace' => true,
2223
'blank_line_after_opening_tag' => true,
2324
'blank_line_before_statement' => true,
24-
'braces' => true,
25+
'blank_line_between_import_groups' => true,
26+
'blank_lines_before_namespace' => true,
27+
'braces' => false, // Deprecated
28+
'braces_position' => true,
2529
'cast_spaces' => true,
2630
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
2731
'class_definition' => true,
32+
'class_keyword' => false, // Because risky, and sometimes we prefer to keep FQCN as is
2833
'class_keyword_remove' => false, // Deprecated, and ::class keyword gives us better support in IDE
34+
'class_reference_name_casing' => true,
35+
'clean_namespace' => true,
2936
'combine_consecutive_issets' => true,
3037
'combine_consecutive_unsets' => true,
3138
'combine_nested_dirname' => true,
3239
'comment_to_phpdoc' => true,
33-
'compact_nullable_typehint' => true,
40+
'compact_nullable_type_declaration' => true,
41+
'compact_nullable_typehint' => false, // Deprecated
3442
'concat_space' => ['spacing' => 'one'],
3543
'constant_case' => true,
44+
'control_structure_braces' => true,
3645
'control_structure_continuation_position' => true,
46+
'curly_braces_position' => false, // Deprecated
47+
'date_time_create_from_format_call' => false, // Because risky
3748
'date_time_immutable' => true,
3849
'declare_equal_normalize' => true,
3950
'declare_parentheses' => true,
@@ -50,7 +61,7 @@
5061
'encoding' => true,
5162
'ereg_to_preg' => true,
5263
'error_suppression' => true,
53-
'escape_implicit_backslashes' => true,
64+
'escape_implicit_backslashes' => false, // Deprecated
5465
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
5566
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
5667
'final_class' => false, // We need non-final classes
@@ -62,12 +73,15 @@
6273
'fully_qualified_strict_types' => true,
6374
'function_declaration' => true,
6475
'function_to_constant' => true,
65-
'function_typehint_space' => true,
76+
'function_typehint_space' => false, // Deprecated
77+
'general_attribute_remove' => true,
6678
'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'category', 'copyright', 'package', 'throws']],
6779
'general_phpdoc_tag_rename' => true,
80+
'get_class_to_class_keyword' => true,
6881
'global_namespace_import' => true,
6982
'group_import' => false, // I feel it makes the code actually harder to read
7083
'header_comment' => false, // We don't use common header in all our files
84+
'heredoc_closing_marker' => ['closing_marker' => 'STRING'],
7185
'heredoc_indentation' => true,
7286
'heredoc_to_nowdoc' => false, // We often use variable in heredoc
7387
'implode_call' => true,
@@ -79,8 +93,9 @@
7993
'lambda_not_used_import' => true,
8094
'line_ending' => true,
8195
'linebreak_after_opening_tag' => true,
82-
'list_syntax' => ['syntax' => 'short'],
96+
'list_syntax' => true,
8397
'logical_operators' => true,
98+
'long_to_shorthand_operator' => false, // Because risky
8499
'lowercase_cast' => true,
85100
'lowercase_keywords' => true,
86101
'lowercase_static_reference' => true,
@@ -92,19 +107,24 @@
92107
'modernize_strpos' => true,
93108
'modernize_types_casting' => true,
94109
'multiline_comment_opening_closing' => true,
110+
'multiline_promoted_properties' => true, // Experimental
111+
'multiline_string_to_heredoc' => false, // We prefer to keep some freedom
95112
'multiline_whitespace_before_semicolons' => true,
96113
'native_constant_invocation' => false, // Micro optimization that look messy
97114
'native_function_casing' => true,
98115
'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
99-
'native_function_type_declaration_casing' => true,
100-
'new_with_braces' => true,
116+
'native_function_type_declaration_casing' => false, // Deprecated
117+
'native_type_declaration_casing' => true,
118+
'new_expression_parentheses' => false, // Requires PHP 8.4
119+
'new_with_braces' => false, // Deprecated
120+
'new_with_parentheses' => true,
101121
'no_alias_functions' => true,
102122
'no_alias_language_construct_call' => true,
103123
'no_alternative_syntax' => true,
104124
'no_binary_string' => true,
105125
'no_blank_lines_after_class_opening' => true,
106126
'no_blank_lines_after_phpdoc' => true,
107-
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
127+
'no_blank_lines_before_namespace' => false, // Deprecated
108128
'no_break_comment' => true,
109129
'no_closing_tag' => true,
110130
'no_empty_comment' => true,
@@ -116,29 +136,35 @@
116136
'no_leading_namespace_whitespace' => true,
117137
'no_mixed_echo_print' => true,
118138
'no_multiline_whitespace_around_double_arrow' => true,
139+
'no_multiple_statements_per_line' => true,
119140
'no_null_property_initialization' => true,
120141
'no_php4_constructor' => true,
121142
'no_short_bool_cast' => true,
122143
'no_singleline_whitespace_before_semicolons' => true,
123144
'no_space_around_double_colon' => true,
124145
'no_spaces_after_function_name' => true,
125146
'no_spaces_around_offset' => true,
126-
'no_spaces_inside_parenthesis' => true,
147+
'no_spaces_inside_parenthesis' => false, // Deprecated
127148
'no_superfluous_elseif' => true,
128149
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
129-
'no_trailing_comma_in_list_call' => true,
130-
'no_trailing_comma_in_singleline_array' => true,
150+
'no_trailing_comma_in_list_call' => false, // Deprecated
151+
'no_trailing_comma_in_singleline' => true,
152+
'no_trailing_comma_in_singleline_array' => false, // Deprecated
153+
'no_trailing_comma_in_singleline_function_call' => true, // Deprecated
131154
'no_trailing_whitespace' => true,
132155
'no_trailing_whitespace_in_comment' => true,
133156
'no_trailing_whitespace_in_string' => false, // Too dangerous
134157
'no_unneeded_control_parentheses' => true,
135-
'no_unneeded_curly_braces' => true,
158+
'no_unneeded_curly_braces' => false, // Deprecated
136159
'no_unneeded_final_method' => true,
160+
'no_unneeded_import_alias' => true,
137161
'no_unreachable_default_argument_value' => true,
138162
'no_unset_cast' => true,
139163
'no_unset_on_property' => true,
140164
'no_unused_imports' => true,
165+
'no_useless_concat_operator' => true,
141166
'no_useless_else' => true,
167+
'no_useless_nullsafe_operator' => true,
142168
'no_useless_return' => true,
143169
'no_useless_sprintf' => true,
144170
'no_whitespace_before_comma_in_array' => true,
@@ -147,15 +173,25 @@
147173
'normalize_index_brace' => true,
148174
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
149175
'not_operator_with_successor_space' => false, // idem
176+
'nullable_type_declaration' => true,
150177
'nullable_type_declaration_for_default_null_value' => true,
178+
'numeric_literal_separator' => false, // Maybe later...
151179
'object_operator_without_whitespace' => true,
152180
'octal_notation' => true,
153181
'operator_linebreak' => true,
182+
'ordered_attributes' => false, // We prefer to keep some freedom
154183
'ordered_class_elements' => false, // We prefer to keep some freedom
155184
'ordered_imports' => true,
156185
'ordered_interfaces' => true,
157186
'ordered_traits' => true,
187+
'ordered_types' => false, // We prefer to keep some freedom
188+
'php_unit_assert_new_names' => true,
189+
'php_unit_attributes' => false, // Requires PHPUnit 10
158190
'php_unit_construct' => true,
191+
'php_unit_data_provider_method_order' => true,
192+
'php_unit_data_provider_name' => ['prefix' => 'provider', 'suffix' => ''],
193+
'php_unit_data_provider_return_type' => true,
194+
'php_unit_data_provider_static' => true,
159195
'php_unit_dedicate_assert' => true,
160196
'php_unit_dedicate_assert_internal_type' => true,
161197
'php_unit_expectation' => true,
@@ -175,16 +211,17 @@
175211
'phpdoc_add_missing_param_annotation' => true,
176212
'phpdoc_align' => false, // Waste of time
177213
'phpdoc_annotation_without_dot' => true,
214+
'phpdoc_array_type' => false, // We prefer `T[]` instead of `array<T>`
178215
'phpdoc_indent' => true,
179216
'phpdoc_inline_tag_normalizer' => true,
180217
'phpdoc_line_span' => true,
218+
'phpdoc_list_type' => false, // Because we are not always sure what type it should actually be
181219
'phpdoc_no_access' => true,
182-
'phpdoc_no_alias_tag' => true,
183220
'phpdoc_no_empty_return' => true,
184-
'phpdoc_no_package' => true,
185-
'phpdoc_no_useless_inheritdoc' => true,
186221
'phpdoc_order' => true,
187222
'phpdoc_order_by_value' => true,
223+
'phpdoc_param_order' => true,
224+
'phpdoc_readonly_class_comment_to_keyword' => true,
188225
'phpdoc_return_self_reference' => true,
189226
'phpdoc_scalar' => true,
190227
'phpdoc_separation' => true,
@@ -208,6 +245,7 @@
208245
'random_api_migration' => true,
209246
'regular_callable_call' => true,
210247
'return_assignment' => false, // Sometimes useful for clarity or debug
248+
'return_to_yield_from' => false, // That seems useless
211249
'return_type_declaration' => true,
212250
'self_accessor' => true,
213251
'self_static_accessor' => true,
@@ -218,21 +256,28 @@
218256
'simplified_if_return' => false, // Even if technically correct we prefer to be explicit
219257
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
220258
'single_blank_line_at_eof' => true,
221-
'single_blank_line_before_namespace' => true,
259+
'single_blank_line_before_namespace' => false, // Deprecated
222260
'single_class_element_per_statement' => true,
223261
'single_import_per_statement' => true,
224262
'single_line_after_imports' => true,
263+
'single_line_comment_spacing' => true,
225264
'single_line_comment_style' => true,
265+
'single_line_empty_body' => true,
226266
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
227267
'single_quote' => true,
228-
'single_space_after_construct' => true,
268+
'single_space_after_construct' => false, // Deprecated
269+
'single_space_around_construct' => true,
229270
'single_trait_insert_per_statement' => true,
230271
'space_after_semicolon' => true,
272+
'spaces_inside_parentheses' => true,
231273
'standardize_increment' => true,
232274
'standardize_not_equals' => true,
275+
'statement_indentation' => true,
233276
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
277+
'static_private_method' => false, // In PHP we'd rather avoid static as a rule of thumb
234278
'strict_comparison' => true,
235279
'strict_param' => true,
280+
'string_implicit_backslashes' => true,
236281
'string_length_to_empty' => true,
237282
'string_line_ending' => true,
238283
'switch_case_semicolon_to_colon' => true,
@@ -241,13 +286,15 @@
241286
'ternary_operator_spaces' => true,
242287
'ternary_to_elvis_operator' => true,
243288
'ternary_to_null_coalescing' => true,
244-
'trailing_comma_in_multiline' => true,
289+
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters']],
245290
'trim_array_spaces' => true,
291+
'type_declaration_spaces' => true,
246292
'types_spaces' => true,
247293
'unary_operator_spaces' => true,
248294
'use_arrow_functions' => true,
249295
'visibility_required' => true,
250296
'void_return' => true,
251297
'whitespace_after_comma_in_array' => true,
252-
'yoda_style' => false,
298+
'yield_from_array_to_yields' => true,
299+
'yoda_style' => false, // Like Yoda we speak not
253300
]);

src/UploadMiddleware.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private function parseUploadedFiles(ServerRequestInterface $request): ServerRequ
6060

6161
if (!array_key_exists($fileKey, $uploadedFiles)) {
6262
throw new RequestError(
63-
"GraphQL query declared an upload in `$location`, but no corresponding file were actually uploaded"
63+
"GraphQL query declared an upload in `$location`, but no corresponding file were actually uploaded",
6464
);
6565
}
6666

@@ -82,19 +82,19 @@ private function validateParsedBody(ServerRequestInterface $request): void
8282

8383
if (null === $bodyParams) {
8484
throw new InvariantViolation(
85-
'PSR-7 request is expected to provide parsed body for "multipart/form-data" requests but got null'
85+
'PSR-7 request is expected to provide parsed body for "multipart/form-data" requests but got null',
8686
);
8787
}
8888

8989
if (!is_array($bodyParams)) {
9090
throw new RequestError(
91-
'GraphQL Server expects JSON object or array, but got ' . Utils::printSafeJson($bodyParams)
91+
'GraphQL Server expects JSON object or array, but got ' . Utils::printSafeJson($bodyParams),
9292
);
9393
}
9494

9595
if (empty($bodyParams)) {
9696
throw new InvariantViolation(
97-
'PSR-7 request is expected to provide parsed body for "multipart/form-data" requests but got empty array'
97+
'PSR-7 request is expected to provide parsed body for "multipart/form-data" requests but got empty array',
9898
);
9999
}
100100
}

tests/UploadMiddlewareTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function testProcess(): void
3838
{
3939
$response = new Response();
4040
$handler = new class($response) implements RequestHandlerInterface {
41-
public function __construct(private readonly ResponseInterface $response)
42-
{
43-
}
41+
public function __construct(
42+
private readonly ResponseInterface $response,
43+
) {}
4444

4545
public function handle(ServerRequestInterface $request): ResponseInterface
4646
{

0 commit comments

Comments
 (0)