Skip to content

Commit c88854b

Browse files
authored
Bumped PHP CS Fixer to v3.89.1 and updated deprecated rules (#18)
For more details see #18 Key changes: * [Composer] Bumped friendsofphp/php-cs-fixer to v3.89.1 * Updated rule set to use '@PER-CS2x0' instead of '@PER-CS2.0' * Fixed non-static call to getRules in `AbstractIbexaRuleSet::buildConfig` * Replaced deprecated rules configuration sets * Explicitly configured `braces_position` rule for 4.6 set * Dropped redundant `no_extra_blank_lines` rule * Explicitly enabled `single_line_empty_body` rule after `braces_position` * Explicitly enabled `blank_line_between_import_groups` rule after `no_extra_blank_lines` * [Tests] Aligned 4.6 expected rule set with the changes
1 parent 62c1a78 commit c88854b

File tree

9 files changed

+76
-58
lines changed

9 files changed

+76
-58
lines changed

.sonarcloud.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
sonar.exclusions=tests/lib/Sets/expected_rules/**/*
1+
# Exclude files from duplication detection
2+
sonar.cpd.exclusions=tests/lib/PhpCsFixer/Sets/expected_rules/**

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"require": {
1616
"php": ">=7.4",
17-
"friendsofphp/php-cs-fixer": "v3.75.0",
17+
"friendsofphp/php-cs-fixer": "v3.89.1",
1818
"composer-runtime-api": ">=2.0"
1919
},
2020
"require-dev": {

src/lib/PhpCsFixer/Sets/AbstractIbexaRuleSet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function getRules(): array
195195
'trailing_comma_in_multiline' => true,
196196
'trim_array_spaces' => true,
197197
'unary_operator_spaces' => true,
198-
'visibility_required' => true,
198+
'modifier_keywords' => true,
199199
'whitespace_after_comma_in_array' => true,
200200
'yoda_style' => false,
201201
'fully_qualified_strict_types' => [
@@ -211,7 +211,7 @@ public function buildConfig(): Config
211211

212212
$config->setRules(array_merge(
213213
$config->getRules(),
214-
static::getRules(),
214+
$this->getRules(),
215215
));
216216

217217
$config->setRiskyAllowed(true);

src/lib/PhpCsFixer/Sets/Ibexa46RuleSet.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@ public function getRules(): array
1515
return array_merge(
1616
parent::getRules(),
1717
[
18-
'no_spaces_inside_parenthesis' => true,
19-
'braces' => [
20-
'allow_single_line_closure' => true,
18+
'spaces_inside_parentheses' => true,
19+
'single_space_around_construct' => true,
20+
'control_structure_braces' => true,
21+
'control_structure_continuation_position' => true,
22+
'no_multiple_statements_per_line' => true,
23+
'declare_parentheses' => true,
24+
'braces_position' => [
25+
'allow_single_line_empty_anonymous_classes' => true,
26+
'allow_single_line_anonymous_functions' => true,
2127
],
22-
'function_typehint_space' => true,
23-
'native_function_type_declaration_casing' => true,
24-
'new_with_braces' => true,
25-
'no_trailing_comma_in_list_call' => true,
26-
'no_trailing_comma_in_singleline_array' => true,
27-
'no_unneeded_curly_braces' => true,
28-
'single_blank_line_before_namespace' => true,
28+
'statement_indentation' => false,
29+
'type_declaration_spaces' => true,
30+
'native_type_declaration_casing' => true,
31+
'new_with_parentheses' => true,
32+
'no_trailing_comma_in_singleline' => true,
33+
'no_unneeded_braces' => true,
34+
'blank_lines_before_namespace' => true,
35+
'single_line_empty_body' => true,
36+
'blank_line_between_import_groups' => true,
2937
],
3038
);
3139
}

src/lib/PhpCsFixer/Sets/Ibexa50RuleSet.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,22 @@ public function getRules(): array
1414
{
1515
return array_merge(
1616
[
17-
'@PER-CS2.0' => true,
17+
'@PER-CS2x0' => true,
1818
],
1919
parent::getRules(),
2020
[
2121
'spaces_inside_parentheses' => [
2222
'space' => 'none',
2323
],
24-
'braces' => [
25-
'allow_single_line_closure' => true,
26-
],
24+
'declare_parentheses' => true,
2725
'type_declaration_spaces' => [
2826
'elements' => [
2927
'function',
3028
'property',
3129
],
3230
],
33-
'native_function_type_declaration_casing' => true,
34-
'new_with_braces' => true,
31+
'native_type_declaration_casing' => true,
32+
'new_with_parentheses' => true,
3533
'no_trailing_comma_in_singleline' => [
3634
'elements' => [
3735
'arguments',
@@ -40,7 +38,7 @@ public function getRules(): array
4038
'group_import',
4139
],
4240
],
43-
'no_unneeded_curly_braces' => true,
41+
'no_unneeded_braces' => true,
4442
'blank_lines_before_namespace' => true,
4543
'class_definition' => [
4644
'single_item_single_line' => true,

tests/lib/PhpCsFixer/Sets/expected_rules/4_6_rule_set/local_rules.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@
2121
'return',
2222
],
2323
],
24-
'braces' => [
25-
'allow_single_line_closure' => true,
24+
'single_space_around_construct' => true,
25+
'control_structure_braces' => true,
26+
'control_structure_continuation_position' => true,
27+
'no_multiple_statements_per_line' => true,
28+
'declare_parentheses' => true,
29+
'braces_position' => [
30+
'allow_single_line_empty_anonymous_classes' => true,
31+
'allow_single_line_anonymous_functions' => true,
2632
],
33+
'statement_indentation' => false,
2734
'cast_spaces' => false,
2835
'class_attributes_separation' => [
2936
'elements' => [
@@ -49,7 +56,7 @@
4956
'full_opening_tag' => true,
5057
'function_declaration' => true,
5158
'function_to_constant' => true,
52-
'function_typehint_space' => true,
59+
'type_declaration_spaces' => true,
5360
'general_phpdoc_tag_rename' => true,
5461
'header_comment' => [
5562
'comment_type' => 'PHPDoc',
@@ -82,8 +89,8 @@
8289
],
8390
'native_function_casing' => true,
8491
'native_function_invocation' => false,
85-
'native_function_type_declaration_casing' => true,
86-
'new_with_braces' => true,
92+
'native_type_declaration_casing' => true,
93+
'new_with_parentheses' => true,
8794
'no_alias_functions' => true,
8895
'no_blank_lines_after_class_opening' => true,
8996
'no_blank_lines_after_phpdoc' => true,
@@ -111,13 +118,12 @@
111118
'no_singleline_whitespace_before_semicolons' => true,
112119
'no_spaces_after_function_name' => true,
113120
'no_spaces_around_offset' => true,
114-
'no_spaces_inside_parenthesis' => true,
115-
'no_trailing_comma_in_list_call' => true,
116-
'no_trailing_comma_in_singleline_array' => true,
121+
'spaces_inside_parentheses' => true,
122+
'no_trailing_comma_in_singleline' => true,
117123
'no_trailing_whitespace' => true,
118124
'no_trailing_whitespace_in_comment' => true,
119125
'no_unneeded_control_parentheses' => true,
120-
'no_unneeded_curly_braces' => true,
126+
'no_unneeded_braces' => true,
121127
'no_unneeded_final_method' => true,
122128
'no_unused_imports' => true,
123129
'no_whitespace_before_comma_in_array' => true,
@@ -170,7 +176,7 @@
170176
'short_scalar_cast' => true,
171177
'simplified_null_return' => false,
172178
'single_blank_line_at_eof' => true,
173-
'single_blank_line_before_namespace' => true,
179+
'blank_lines_before_namespace' => true,
174180
'single_class_element_per_statement' => true,
175181
'single_import_per_statement' => true,
176182
'single_line_after_imports' => true,
@@ -191,11 +197,13 @@
191197
'trailing_comma_in_multiline' => true,
192198
'trim_array_spaces' => true,
193199
'unary_operator_spaces' => true,
194-
'visibility_required' => true,
200+
'modifier_keywords' => true,
195201
'whitespace_after_comma_in_array' => true,
196202
'yoda_style' => false,
197203
'Ibexa/multiline_parameters' => true,
198204
'fully_qualified_strict_types' => [
199205
'import_symbols' => true,
200206
],
207+
'single_line_empty_body' => true,
208+
'blank_line_between_import_groups' => true,
201209
];

tests/lib/PhpCsFixer/Sets/expected_rules/4_6_rule_set/php_cs_fixer_rules.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'declare_equal_normalize' => true,
1212
'lowercase_cast' => true,
1313
'lowercase_static_reference' => true,
14-
'new_with_braces' => true,
14+
'new_with_parentheses' => true,
1515
'no_blank_lines_after_class_opening' => true,
1616
'no_leading_import_slash' => true,
1717
'no_whitespace_in_blank_line' => true,
@@ -21,7 +21,7 @@
2121
'single_import_per_statement' => true,
2222
'single_trait_insert_per_statement' => true,
2323
'ternary_operator_spaces' => true,
24-
'visibility_required' => true,
24+
'modifier_keywords' => true,
2525
'blank_line_after_namespace' => true,
2626
'constant_case' => [
2727
'case' => 'lower',
@@ -168,18 +168,25 @@
168168
'concat_space' => [
169169
'spacing' => 'one',
170170
],
171-
'braces' => [
172-
'allow_single_line_closure' => true,
171+
'braces_position' => [
172+
'allow_single_line_empty_anonymous_classes' => true,
173+
'allow_single_line_anonymous_functions' => true,
173174
],
174-
'no_spaces_inside_parenthesis' => true,
175-
'function_typehint_space' => true,
176-
'native_function_type_declaration_casing' => true,
177-
'no_trailing_comma_in_list_call' => true,
178-
'no_trailing_comma_in_singleline_array' => true,
179-
'no_unneeded_curly_braces' => true,
180-
'single_blank_line_before_namespace' => true,
175+
'single_space_around_construct' => true,
176+
'control_structure_braces' => true,
177+
'control_structure_continuation_position' => true,
178+
'no_multiple_statements_per_line' => true,
179+
'declare_parentheses' => true,
180+
'spaces_inside_parentheses' => true,
181+
'type_declaration_spaces' => true,
182+
'native_type_declaration_casing' => true,
183+
'no_trailing_comma_in_singleline' => true,
184+
'no_unneeded_braces' => true,
185+
'blank_lines_before_namespace' => true,
181186
'Ibexa/multiline_parameters' => true,
182187
'fully_qualified_strict_types' => [
183188
'import_symbols' => true,
184189
],
190+
'single_line_empty_body' => true,
191+
'blank_line_between_import_groups' => true,
185192
];

tests/lib/PhpCsFixer/Sets/expected_rules/5_0_rule_set/local_rules.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Ibexa\CodeStyle\PhpCsFixer\Sets\AbstractIbexaRuleSet;
1010

1111
return [
12-
'@PER-CS2.0' => true,
12+
'@PER-CS2x0' => true,
1313
'@PSR12' => false,
1414
'array_syntax' => [
1515
'syntax' => 'short',
@@ -23,9 +23,8 @@
2323
],
2424
],
2525
'blank_lines_before_namespace' => true,
26-
'braces' => [
27-
'allow_single_line_closure' => true,
28-
],
26+
'declare_parentheses' => true,
27+
'no_unneeded_braces' => true,
2928
'cast_spaces' => false,
3029
'class_attributes_separation' => [
3130
'elements' => [
@@ -86,8 +85,8 @@
8685
],
8786
'native_function_casing' => true,
8887
'native_function_invocation' => false,
89-
'native_function_type_declaration_casing' => true,
90-
'new_with_braces' => true,
88+
'native_type_declaration_casing' => true,
89+
'new_with_parentheses' => true,
9190
'no_alias_functions' => true,
9291
'no_blank_lines_after_class_opening' => true,
9392
'no_blank_lines_after_phpdoc' => true,
@@ -126,7 +125,6 @@
126125
'no_trailing_whitespace' => true,
127126
'no_trailing_whitespace_in_comment' => true,
128127
'no_unneeded_control_parentheses' => true,
129-
'no_unneeded_curly_braces' => true,
130128
'no_unneeded_final_method' => true,
131129
'no_unused_imports' => true,
132130
'no_whitespace_before_comma_in_array' => true,
@@ -214,7 +212,7 @@
214212
'space' => 'single',
215213
],
216214
'unary_operator_spaces' => true,
217-
'visibility_required' => true,
215+
'modifier_keywords' => true,
218216
'whitespace_after_comma_in_array' => true,
219217
'yoda_style' => false,
220218
'Ibexa/multiline_parameters' => true,

tests/lib/PhpCsFixer/Sets/expected_rules/5_0_rule_set/php_cs_fixer_rules.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
'declare_equal_normalize' => true,
2222
'lowercase_cast' => true,
2323
'lowercase_static_reference' => true,
24-
'new_with_braces' => true,
2524
'no_blank_lines_after_class_opening' => true,
2625
'no_leading_import_slash' => true,
2726
'no_whitespace_in_blank_line' => true,
@@ -31,7 +30,7 @@
3130
'single_import_per_statement' => true,
3231
'single_trait_insert_per_statement' => true,
3332
'ternary_operator_spaces' => true,
34-
'visibility_required' => true,
33+
'modifier_keywords' => true,
3534
'blank_line_after_namespace' => true,
3635
'constant_case' => [
3736
'case' => 'lower',
@@ -178,16 +177,15 @@
178177
'trim_array_spaces' => true,
179178
'unary_operator_spaces' => true,
180179
'whitespace_after_comma_in_array' => true,
181-
'braces' => [
182-
'allow_single_line_closure' => true,
183-
],
180+
'declare_parentheses' => true,
181+
'new_with_parentheses' => true,
184182
'type_declaration_spaces' => [
185183
'elements' => [
186184
'function',
187185
'property',
188186
],
189187
],
190-
'native_function_type_declaration_casing' => true,
188+
'native_type_declaration_casing' => true,
191189
'no_trailing_comma_in_singleline' => [
192190
'elements' => [
193191
'arguments',
@@ -196,7 +194,7 @@
196194
'group_import',
197195
],
198196
],
199-
'no_unneeded_curly_braces' => true,
197+
'no_unneeded_braces' => true,
200198
'php_unit_test_case_static_method_calls' => [
201199
'call_type' => 'self',
202200
],

0 commit comments

Comments
 (0)