Skip to content

Commit 446aee6

Browse files
committed
Update php-cs-fixer configuration #11599
1 parent 06b13bb commit 446aee6

32 files changed

+230
-196
lines changed

.php-cs-fixer.dist.php

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,35 @@
2121
'array_push' => true,
2222
'array_syntax' => ['syntax' => 'short'],
2323
'assign_null_coalescing_to_coalesce_equal' => true,
24+
'attribute_empty_parentheses' => true,
2425
'backtick_to_shell_exec' => true,
2526
'binary_operator_spaces' => true,
2627
'blank_line_after_namespace' => true,
2728
'blank_line_after_opening_tag' => true,
2829
'blank_line_before_statement' => true,
29-
'braces' => true,
30+
'blank_line_between_import_groups' => true,
31+
'blank_lines_before_namespace' => true,
32+
'braces' => false, // Deprecated
33+
'braces_position' => true,
3034
'cast_spaces' => true,
3135
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
3236
'class_definition' => true,
37+
'class_keyword' => false, // Because risky, and sometimes we prefer to keep FQCN as is
3338
'class_keyword_remove' => false, // Deprecated, and ::class keyword gives us better support in IDE
39+
'class_reference_name_casing' => true,
40+
'clean_namespace' => true,
3441
'combine_consecutive_issets' => true,
3542
'combine_consecutive_unsets' => true,
3643
'combine_nested_dirname' => true,
3744
'comment_to_phpdoc' => true,
38-
'compact_nullable_typehint' => true,
45+
'compact_nullable_type_declaration' => true,
46+
'compact_nullable_typehint' => false, // Deprecated
3947
'concat_space' => ['spacing' => 'one'],
4048
'constant_case' => true,
49+
'control_structure_braces' => true,
4150
'control_structure_continuation_position' => true,
51+
'curly_braces_position' => false, // Deprecated
52+
'date_time_create_from_format_call' => false, // Because risky
4253
'date_time_immutable' => true,
4354
'declare_equal_normalize' => true,
4455
'declare_parentheses' => true,
@@ -55,7 +66,7 @@
5566
'encoding' => true,
5667
'ereg_to_preg' => true,
5768
'error_suppression' => true,
58-
'escape_implicit_backslashes' => true,
69+
'escape_implicit_backslashes' => false, // Deprecated
5970
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
6071
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
6172
'final_class' => false, // We need non-final classes
@@ -67,12 +78,15 @@
6778
'fully_qualified_strict_types' => true,
6879
'function_declaration' => true,
6980
'function_to_constant' => true,
70-
'function_typehint_space' => true,
81+
'function_typehint_space' => false, // Deprecated
82+
'general_attribute_remove' => true,
7183
'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'category', 'copyright', 'package', 'throws']],
7284
'general_phpdoc_tag_rename' => true,
85+
'get_class_to_class_keyword' => true,
7386
'global_namespace_import' => true,
7487
'group_import' => false, // I feel it makes the code actually harder to read
7588
'header_comment' => false, // We don't use common header in all our files
89+
'heredoc_closing_marker' => ['closing_marker' => 'STRING'],
7690
'heredoc_indentation' => true,
7791
'heredoc_to_nowdoc' => false, // We often use variable in heredoc
7892
'implode_call' => true,
@@ -84,8 +98,9 @@
8498
'lambda_not_used_import' => true,
8599
'line_ending' => true,
86100
'linebreak_after_opening_tag' => true,
87-
'list_syntax' => ['syntax' => 'short'],
101+
'list_syntax' => true,
88102
'logical_operators' => true,
103+
'long_to_shorthand_operator' => false, // Because risky
89104
'lowercase_cast' => true,
90105
'lowercase_keywords' => true,
91106
'lowercase_static_reference' => true,
@@ -97,19 +112,24 @@
97112
'modernize_strpos' => true,
98113
'modernize_types_casting' => true,
99114
'multiline_comment_opening_closing' => true,
115+
'multiline_promoted_properties' => true, // Experimental
116+
'multiline_string_to_heredoc' => false, // We prefer to keep some freedom
100117
'multiline_whitespace_before_semicolons' => true,
101118
'native_constant_invocation' => false, // Micro optimization that look messy
102119
'native_function_casing' => true,
103120
'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
104-
'native_function_type_declaration_casing' => true,
105-
'new_with_braces' => true,
121+
'native_function_type_declaration_casing' => false, // Deprecated
122+
'native_type_declaration_casing' => true,
123+
'new_expression_parentheses' => false, // Requires PHP 8.4
124+
'new_with_braces' => false, // Deprecated
125+
'new_with_parentheses' => true,
106126
'no_alias_functions' => true,
107127
'no_alias_language_construct_call' => true,
108-
'no_alternative_syntax' => true,
128+
'no_alternative_syntax' => false, // We want to use alternative syntax in .phtml
109129
'no_binary_string' => true,
110130
'no_blank_lines_after_class_opening' => true,
111131
'no_blank_lines_after_phpdoc' => true,
112-
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
132+
'no_blank_lines_before_namespace' => false, // Deprecated
113133
'no_break_comment' => true,
114134
'no_closing_tag' => true,
115135
'no_empty_comment' => true,
@@ -121,29 +141,35 @@
121141
'no_leading_namespace_whitespace' => true,
122142
'no_mixed_echo_print' => true,
123143
'no_multiline_whitespace_around_double_arrow' => true,
144+
'no_multiple_statements_per_line' => true,
124145
'no_null_property_initialization' => true,
125146
'no_php4_constructor' => true,
126147
'no_short_bool_cast' => true,
127148
'no_singleline_whitespace_before_semicolons' => true,
128149
'no_space_around_double_colon' => true,
129150
'no_spaces_after_function_name' => true,
130151
'no_spaces_around_offset' => true,
131-
'no_spaces_inside_parenthesis' => true,
152+
'no_spaces_inside_parenthesis' => false, // Deprecated
132153
'no_superfluous_elseif' => true,
133154
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
134-
'no_trailing_comma_in_list_call' => true,
135-
'no_trailing_comma_in_singleline_array' => true,
155+
'no_trailing_comma_in_list_call' => false, // Deprecated
156+
'no_trailing_comma_in_singleline' => true,
157+
'no_trailing_comma_in_singleline_array' => false, // Deprecated
158+
'no_trailing_comma_in_singleline_function_call' => true, // Deprecated
136159
'no_trailing_whitespace' => true,
137160
'no_trailing_whitespace_in_comment' => true,
138161
'no_trailing_whitespace_in_string' => false, // Too dangerous
139162
'no_unneeded_control_parentheses' => true,
140-
'no_unneeded_curly_braces' => true,
163+
'no_unneeded_curly_braces' => false, // Deprecated
141164
'no_unneeded_final_method' => true,
165+
'no_unneeded_import_alias' => true,
142166
'no_unreachable_default_argument_value' => true,
143167
'no_unset_cast' => true,
144168
'no_unset_on_property' => true,
145169
'no_unused_imports' => true,
170+
'no_useless_concat_operator' => true,
146171
'no_useless_else' => true,
172+
'no_useless_nullsafe_operator' => true,
147173
'no_useless_return' => true,
148174
'no_useless_sprintf' => true,
149175
'no_whitespace_before_comma_in_array' => true,
@@ -152,15 +178,25 @@
152178
'normalize_index_brace' => true,
153179
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
154180
'not_operator_with_successor_space' => false, // idem
181+
'nullable_type_declaration' => true,
155182
'nullable_type_declaration_for_default_null_value' => true,
183+
'numeric_literal_separator' => false, // Maybe later...
156184
'object_operator_without_whitespace' => true,
157185
'octal_notation' => true,
158186
'operator_linebreak' => true,
187+
'ordered_attributes' => false, // We prefer to keep some freedom
159188
'ordered_class_elements' => false, // We prefer to keep some freedom
160189
'ordered_imports' => true,
161190
'ordered_interfaces' => true,
162191
'ordered_traits' => true,
192+
'ordered_types' => false, // We prefer to keep some freedom
193+
'php_unit_assert_new_names' => true,
194+
'php_unit_attributes' => false, // Requires PHPUnit 10
163195
'php_unit_construct' => true,
196+
'php_unit_data_provider_method_order' => true,
197+
'php_unit_data_provider_name' => ['prefix' => 'provider', 'suffix' => ''],
198+
'php_unit_data_provider_return_type' => true,
199+
'php_unit_data_provider_static' => true,
164200
'php_unit_dedicate_assert' => true,
165201
'php_unit_dedicate_assert_internal_type' => true,
166202
'php_unit_expectation' => true,
@@ -180,16 +216,17 @@
180216
'phpdoc_add_missing_param_annotation' => true,
181217
'phpdoc_align' => false, // Waste of time
182218
'phpdoc_annotation_without_dot' => true,
219+
'phpdoc_array_type' => false, // We prefer `T[]` instead of `array<T>`
183220
'phpdoc_indent' => true,
184221
'phpdoc_inline_tag_normalizer' => true,
185222
'phpdoc_line_span' => true,
223+
'phpdoc_list_type' => false, // Because we are not always sure what type it should actually be
186224
'phpdoc_no_access' => true,
187-
'phpdoc_no_alias_tag' => true,
188225
'phpdoc_no_empty_return' => true,
189-
'phpdoc_no_package' => true,
190-
'phpdoc_no_useless_inheritdoc' => true,
191226
'phpdoc_order' => true,
192227
'phpdoc_order_by_value' => true,
228+
'phpdoc_param_order' => true,
229+
'phpdoc_readonly_class_comment_to_keyword' => true,
193230
'phpdoc_return_self_reference' => true,
194231
'phpdoc_scalar' => true,
195232
'phpdoc_separation' => true,
@@ -213,6 +250,7 @@
213250
'random_api_migration' => true,
214251
'regular_callable_call' => true,
215252
'return_assignment' => false, // Sometimes useful for clarity or debug
253+
'return_to_yield_from' => false, // That seems useless
216254
'return_type_declaration' => true,
217255
'self_accessor' => true,
218256
'self_static_accessor' => true,
@@ -223,21 +261,28 @@
223261
'simplified_if_return' => false, // Even if technically correct we prefer to be explicit
224262
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
225263
'single_blank_line_at_eof' => true,
226-
'single_blank_line_before_namespace' => true,
264+
'single_blank_line_before_namespace' => false, // Deprecated
227265
'single_class_element_per_statement' => true,
228266
'single_import_per_statement' => true,
229267
'single_line_after_imports' => true,
268+
'single_line_comment_spacing' => true,
230269
'single_line_comment_style' => true,
270+
'single_line_empty_body' => true,
231271
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
232272
'single_quote' => true,
233-
'single_space_after_construct' => true,
273+
'single_space_after_construct' => false, // Deprecated
274+
'single_space_around_construct' => true,
234275
'single_trait_insert_per_statement' => true,
235276
'space_after_semicolon' => true,
277+
'spaces_inside_parentheses' => true,
236278
'standardize_increment' => true,
237279
'standardize_not_equals' => true,
280+
'statement_indentation' => true,
238281
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
282+
'static_private_method' => false, // In PHP we'd rather avoid static as a rule of thumb
239283
'strict_comparison' => true,
240284
'strict_param' => true,
285+
'string_implicit_backslashes' => true,
241286
'string_length_to_empty' => true,
242287
'string_line_ending' => true,
243288
'switch_case_semicolon_to_colon' => true,
@@ -246,13 +291,15 @@
246291
'ternary_operator_spaces' => true,
247292
'ternary_to_elvis_operator' => true,
248293
'ternary_to_null_coalescing' => true,
249-
'trailing_comma_in_multiline' => true,
294+
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters']],
250295
'trim_array_spaces' => true,
296+
'type_declaration_spaces' => true,
251297
'types_spaces' => true,
252298
'unary_operator_spaces' => true,
253299
'use_arrow_functions' => true,
254300
'visibility_required' => true,
255301
'void_return' => true,
256302
'whitespace_after_comma_in_array' => true,
257-
'yoda_style' => false,
303+
'yield_from_array_to_yields' => true,
304+
'yoda_style' => false, // Like Yoda we speak not
258305
]);

bin/clear-config-cache.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
printf(
2828
"Configured config cache file '%s' not found%s",
2929
$config['config_cache_path'],
30-
PHP_EOL
30+
PHP_EOL,
3131
);
3232
exit(0);
3333
}
@@ -36,14 +36,14 @@
3636
printf(
3737
"Error removing config cache file '%s'%s",
3838
$config['config_cache_path'],
39-
PHP_EOL
39+
PHP_EOL,
4040
);
4141
exit(1);
4242
}
4343

4444
printf(
4545
"Removed configured config cache file '%s'%s",
4646
$config['config_cache_path'],
47-
PHP_EOL
47+
PHP_EOL,
4848
);
4949
exit(0);

server/Application/Api/Input/Sorting/Illustration.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
*/
1515
class Illustration implements SortingInterface
1616
{
17-
public function __construct()
18-
{
19-
}
17+
public function __construct() {}
2018

2119
public function __invoke(UniqueNameFactory $uniqueNameFactory, ClassMetadata $metadata, QueryBuilder $queryBuilder, string $alias, string $order): void
2220
{

server/Application/Api/Input/Sorting/Owner.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616
class Owner implements SortingInterface
1717
{
18-
public function __construct()
19-
{
20-
}
18+
public function __construct() {}
2119

2220
public function __invoke(UniqueNameFactory $uniqueNameFactory, ClassMetadata $metadata, QueryBuilder $queryBuilder, string $alias, string $order): void
2321
{

server/Application/Handler/DatatransHandler.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626

2727
class DatatransHandler extends AbstractHandler
2828
{
29-
public function __construct(private readonly EntityManager $entityManager, private readonly TemplateRendererInterface $template, private readonly array $config, private readonly Mailer $mailer, private readonly MessageQueuer $messageQueuer)
30-
{
31-
}
29+
public function __construct(
30+
private readonly EntityManager $entityManager,
31+
private readonly TemplateRendererInterface $template,
32+
private readonly array $config,
33+
private readonly Mailer $mailer,
34+
private readonly MessageQueuer $messageQueuer,
35+
) {}
3236

3337
/**
3438
* Webhook called by datatrans when a payment was made.

server/Application/Handler/SitemapHandler.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414

1515
class SitemapHandler implements \Psr\Http\Server\RequestHandlerInterface
1616
{
17-
public function __construct(private readonly ProductRepository $productRepository, private readonly NewsRepository $newsRepository, private readonly string $baseUrl, private readonly array $sitemapStaticUrls)
18-
{
19-
}
17+
public function __construct(
18+
private readonly ProductRepository $productRepository,
19+
private readonly NewsRepository $newsRepository,
20+
private readonly string $baseUrl,
21+
private readonly array $sitemapStaticUrls,
22+
) {}
2023

2124
public function handle(ServerRequestInterface $request): ResponseInterface
2225
{

server/Application/Middleware/AuthenticationMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
class AuthenticationMiddleware implements MiddlewareInterface
1717
{
18-
public function __construct(private readonly UserRepository $userRepository)
19-
{
20-
}
18+
public function __construct(
19+
private readonly UserRepository $userRepository,
20+
) {}
2121

2222
/**
2323
* Load current user from session if exists and still valid.

server/Application/Model/Configuration.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ class Configuration extends AbstractModel
2121

2222
public function __construct(
2323
#[ORM\Column(name: '`key`', type: 'string', length: 191, unique: true)]
24-
private string $key = ''
25-
) {
26-
}
24+
private string $key = '',
25+
) {}
2726

2827
/**
2928
* Get key.

server/Application/Model/Organization.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ class Organization extends AbstractModel
3030
#[ORM\Column(type: 'text')]
3131
private string $pattern;
3232

33-
public function __construct()
34-
{
35-
}
33+
public function __construct() {}
3634

3735
public function setPattern(string $pattern): self
3836
{

server/Application/Repository/CommentRepository.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99
/**
1010
* @extends AbstractRepository<Comment>
1111
*/
12-
class CommentRepository extends AbstractRepository
13-
{
14-
}
12+
class CommentRepository extends AbstractRepository {}

0 commit comments

Comments
 (0)