Skip to content

Commit e16843d

Browse files
Merge branch '5.1'
2 parents 059ddc5 + a4c3148 commit e16843d

19 files changed

+123
-107
lines changed

.php-cs-fixer.dist.php

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
'backtick_to_shell_exec' => true,
2626
'binary_operator_spaces' => [
2727
'operators' => [
28+
'*=' => 'align_single_space_minimal',
29+
'+=' => 'align_single_space_minimal',
30+
'-=' => 'align_single_space_minimal',
31+
'/=' => 'align_single_space_minimal',
2832
'=' => 'align_single_space_minimal',
2933
'=>' => 'align_single_space_minimal',
3034
],
@@ -57,6 +61,14 @@
5761
'yield_from',
5862
],
5963
],
64+
'blank_lines_before_namespace' => [
65+
'max_line_breaks' => 1,
66+
'min_line_breaks' => 0,
67+
],
68+
'braces_position' => [
69+
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
70+
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
71+
],
6072
'cast_spaces' => true,
6173
'class_attributes_separation' => [
6274
'elements' => [
@@ -70,15 +82,11 @@
7082
'combine_consecutive_issets' => true,
7183
'combine_consecutive_unsets' => true,
7284
'combine_nested_dirname' => true,
73-
'compact_nullable_typehint' => true,
85+
'compact_nullable_type_declaration' => true,
7486
'concat_space' => ['spacing' => 'one'],
7587
'constant_case' => true,
7688
'control_structure_braces' => true,
7789
'control_structure_continuation_position' => true,
78-
'curly_braces_position' => [
79-
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
80-
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
81-
],
8290
'declare_equal_normalize' => ['space' => 'none'],
8391
'declare_parentheses' => true,
8492
'declare_strict_types' => true,
@@ -94,7 +102,6 @@
94102
'fully_qualified_strict_types' => true,
95103
'function_declaration' => true,
96104
'function_to_constant' => true,
97-
'function_typehint_space' => true,
98105
'get_class_to_class_keyword' => true,
99106
'global_namespace_import' => [
100107
'import_classes' => true,
@@ -106,9 +113,10 @@
106113
'implode_call' => true,
107114
'include' => true,
108115
'increment_style' => [
109-
'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
116+
'style' => 'post',
110117
],
111118
'indentation_type' => true,
119+
'integer_literal_case' => true,
112120
'is_null' => true,
113121
'lambda_not_used_import' => true,
114122
'line_ending' => true,
@@ -122,6 +130,8 @@
122130
'method_argument_space' => [
123131
'on_multiline' => 'ensure_fully_multiline',
124132
],
133+
'method_chaining_indentation' => true,
134+
'modernize_strpos' => true,
125135
'modernize_types_casting' => true,
126136
'multiline_comment_opening_closing' => true,
127137
'multiline_whitespace_before_semicolons' => true,
@@ -132,18 +142,17 @@
132142
'@internal',
133143
],
134144
],
135-
'native_function_type_declaration_casing' => true,
136-
'new_with_braces' => [
137-
'named_class' => false,
145+
'native_type_declaration_casing' => true,
146+
'new_with_parentheses' => [
138147
'anonymous_class' => false,
148+
'named_class' => false,
139149
],
140150
'no_alias_functions' => true,
141151
'no_alias_language_construct_call' => true,
142152
'no_alternative_syntax' => true,
143153
'no_binary_string' => true,
144154
'no_blank_lines_after_class_opening' => true,
145155
'no_blank_lines_after_phpdoc' => true,
146-
'no_blank_lines_before_namespace' => true,
147156
'no_break_comment' => true,
148157
'no_closing_tag' => true,
149158
'no_empty_comment' => true,
@@ -154,15 +163,15 @@
154163
'no_leading_import_slash' => true,
155164
'no_leading_namespace_whitespace' => true,
156165
'no_mixed_echo_print' => ['use' => 'print'],
157-
'no_multiple_statements_per_line' => true,
158166
'no_multiline_whitespace_around_double_arrow' => true,
167+
'no_multiple_statements_per_line' => true,
159168
'no_null_property_initialization' => true,
160169
'no_php4_constructor' => true,
161170
'no_short_bool_cast' => true,
162171
'no_singleline_whitespace_before_semicolons' => true,
172+
'no_space_around_double_colon' => true,
163173
'no_spaces_after_function_name' => true,
164174
'no_spaces_around_offset' => true,
165-
'no_spaces_inside_parenthesis' => true,
166175
'no_superfluous_elseif' => true,
167176
'no_superfluous_phpdoc_tags' => [
168177
'allow_mixed' => true,
@@ -171,22 +180,25 @@
171180
'no_trailing_whitespace' => true,
172181
'no_trailing_whitespace_in_comment' => true,
173182
'no_trailing_whitespace_in_string' => true,
183+
'no_unneeded_braces' => true,
174184
'no_unneeded_control_parentheses' => true,
175-
'no_unneeded_curly_braces' => true,
176185
'no_unneeded_final_method' => true,
177186
'no_unneeded_import_alias' => true,
178187
'no_unreachable_default_argument_value' => true,
179188
'no_unset_cast' => true,
180189
'no_unset_on_property' => true,
181190
'no_unused_imports' => true,
191+
'no_useless_concat_operator' => true,
182192
'no_useless_else' => true,
193+
'no_useless_nullsafe_operator' => true,
183194
'no_useless_return' => true,
184195
'no_useless_sprintf' => true,
185196
'no_whitespace_before_comma_in_array' => true,
186197
'no_whitespace_in_blank_line' => true,
187198
'non_printable_character' => true,
188199
'normalize_index_brace' => true,
189200
'object_operator_without_whitespace' => true,
201+
'octal_notation' => true,
190202
'operator_linebreak' => [
191203
'only_booleans' => true,
192204
'position' => 'end',
@@ -217,16 +229,17 @@
217229
],
218230
'ordered_imports' => [
219231
'imports_order' => [
220-
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
221-
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
222-
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
232+
'const',
233+
'function',
234+
'class',
223235
]
224236
],
225237
'ordered_interfaces' => [
226238
'direction' => 'ascend',
227239
'order' => 'alpha',
228240
],
229241
'ordered_traits' => true,
242+
'ordered_types' => true,
230243
'php_unit_set_up_tear_down_visibility' => true,
231244
'php_unit_test_case_static_method_calls' => [
232245
'call_type' => 'this',
@@ -250,14 +263,15 @@
250263
'uses',
251264
],
252265
],
266+
'phpdoc_param_order' => true,
253267
'phpdoc_return_self_reference' => true,
254268
'phpdoc_scalar' => true,
255269
'phpdoc_separation' => true,
256270
'phpdoc_single_line_var_spacing' => true,
257271
'phpdoc_summary' => true,
258272
'phpdoc_tag_casing' => true,
259273
'phpdoc_tag_type' => true,
260-
'phpdoc_to_comment' => true,
274+
'phpdoc_to_comment' => false,
261275
'phpdoc_trim' => true,
262276
'phpdoc_trim_consecutive_blank_line_separation' => true,
263277
'phpdoc_types' => ['groups' => ['simple', 'meta']],
@@ -279,15 +293,20 @@
279293
'single_class_element_per_statement' => true,
280294
'single_import_per_statement' => true,
281295
'single_line_after_imports' => true,
296+
'single_line_comment_spacing' => true,
282297
'single_quote' => true,
283298
'single_space_around_construct' => true,
284299
'single_trait_insert_per_statement' => true,
285300
'space_after_semicolon' => true,
301+
'spaces_inside_parentheses' => [
302+
'space' => 'none',
303+
],
286304
'standardize_increment' => true,
287305
'standardize_not_equals' => true,
288306
'statement_indentation' => true,
289307
'static_lambda' => true,
290308
'strict_param' => true,
309+
'string_length_to_empty'=> true,
291310
'string_line_ending' => true,
292311
'switch_case_semicolon_to_colon' => true,
293312
'switch_case_space' => true,
@@ -297,13 +316,18 @@
297316
'ternary_to_null_coalescing' => true,
298317
'trailing_comma_in_multiline' => [
299318
'elements' => [
300-
'arrays'
319+
'arguments',
320+
'arrays',
321+
'match',
301322
]
302323
],
303324
'trim_array_spaces' => true,
304-
'types_spaces' => [
305-
'space' => 'none',
325+
'type_declaration_spaces' => [
326+
'elements' => [
327+
'function',
328+
],
306329
],
330+
'types_spaces' => true,
307331
'unary_operator_spaces' => true,
308332
'visibility_required' => [
309333
'elements' => [

src/Exception/ConfigurationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function __construct(
2828
'Option "%s" must be %s, got "%s".',
2929
$option,
3030
$expected,
31-
is_object($value) ? $value::class : (null === $value ? '<null>' : gettype($value) . '#' . $value)
31+
is_object($value) ? $value::class : (null === $value ? '<null>' : gettype($value) . '#' . $value),
3232
),
3333
$code,
34-
$previous
34+
$previous,
3535
);
3636
}
3737
}

src/MemoryEfficientLongestCommonSubsequenceCalculator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function calculate(array $from, array $to): array
6161

6262
return array_merge(
6363
$this->calculate($fromStart, $toStart),
64-
$this->calculate($fromEnd, $toEnd)
64+
$this->calculate($fromEnd, $toEnd),
6565
);
6666
}
6767

@@ -78,7 +78,11 @@ private function length(array $from, array $to): array
7878
if ($from[$i] === $to[$j]) {
7979
$current[$j + 1] = $prev[$j] + 1;
8080
} else {
81-
// don't use max() to avoid function call overhead
81+
/**
82+
* @noinspection PhpConditionCanBeReplacedWithMinMaxCallInspection
83+
*
84+
* We do not use max() here to avoid the function call overhead
85+
*/
8286
if ($current[$j] > $prev[$j + 1]) {
8387
$current[$j + 1] = $current[$j];
8488
} else {

src/Output/StrictUnifiedDiffOutputBuilder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __construct(array $options = [])
8282
$options['fromFile'],
8383
null === $options['fromFileDate'] ? '' : "\t" . $options['fromFileDate'],
8484
$options['toFile'],
85-
null === $options['toFileDate'] ? '' : "\t" . $options['toFileDate']
85+
null === $options['toFileDate'] ? '' : "\t" . $options['toFileDate'],
8686
);
8787

8888
$this->collapseRanges = $options['collapseRanges'];
@@ -201,11 +201,11 @@ private function writeDiffHunks($output, array $diff): void
201201
$fromRange - $cutOff + $contextStartOffset + $this->contextLines,
202202
$toStart - $contextStartOffset,
203203
$toRange - $cutOff + $contextStartOffset + $this->contextLines,
204-
$output
204+
$output,
205205
);
206206

207207
$fromStart += $fromRange;
208-
$toStart += $toRange;
208+
$toStart += $toRange;
209209

210210
$hunkCapture = false;
211211
$sameCount = $toRange = $fromRange = 0;
@@ -251,7 +251,7 @@ private function writeDiffHunks($output, array $diff): void
251251
$contextEndOffset = min($sameCount, $this->contextLines);
252252

253253
$fromRange -= $sameCount;
254-
$toRange -= $sameCount;
254+
$toRange -= $sameCount;
255255

256256
$this->writeHunk(
257257
$diff,
@@ -261,7 +261,7 @@ private function writeDiffHunks($output, array $diff): void
261261
$fromRange + $contextStartOffset + $contextEndOffset,
262262
$toStart - $contextStartOffset,
263263
$toRange + $contextStartOffset + $contextEndOffset,
264-
$output
264+
$output,
265265
);
266266
}
267267

@@ -302,11 +302,11 @@ private function writeHunk(
302302
$this->changed = true;
303303
fwrite($output, $diff[$i][0]);
304304
}
305-
//} elseif ($diff[$i][1] === Differ::DIFF_LINE_END_WARNING) { // custom comment inserted by PHPUnit/diff package
305+
// } elseif ($diff[$i][1] === Differ::DIFF_LINE_END_WARNING) { // custom comment inserted by PHPUnit/diff package
306306
// skip
307-
//} else {
307+
// } else {
308308
// unknown/invalid
309-
//}
309+
// }
310310
}
311311
}
312312

src/Output/UnifiedDiffOutputBuilder.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use function min;
1919
use function str_ends_with;
2020
use function stream_get_contents;
21-
use function strlen;
2221
use function substr;
2322
use SebastianBergmann\Diff\Differ;
2423

@@ -67,7 +66,7 @@ public function getDiff(array $diff): string
6766
// This might happen when both the `from` and `to` do not have a trailing linebreak
6867
$last = substr($diff, -1);
6968

70-
return 0 !== strlen($diff) && "\n" !== $last && "\r" !== $last
69+
return '' !== $diff && "\n" !== $last && "\r" !== $last
7170
? $diff . "\n"
7271
: $diff;
7372
}
@@ -151,11 +150,11 @@ private function writeDiffHunks($output, array $diff): void
151150
$fromRange - $cutOff + $contextStartOffset + $this->contextLines,
152151
$toStart - $contextStartOffset,
153152
$toRange - $cutOff + $contextStartOffset + $this->contextLines,
154-
$output
153+
$output,
155154
);
156155

157156
$fromStart += $fromRange;
158-
$toStart += $toRange;
157+
$toStart += $toRange;
159158

160159
$hunkCapture = false;
161160
$sameCount = $toRange = $fromRange = 0;
@@ -199,7 +198,7 @@ private function writeDiffHunks($output, array $diff): void
199198
$contextEndOffset = min($sameCount, $this->contextLines);
200199

201200
$fromRange -= $sameCount;
202-
$toRange -= $sameCount;
201+
$toRange -= $sameCount;
203202

204203
$this->writeHunk(
205204
$diff,
@@ -209,7 +208,7 @@ private function writeDiffHunks($output, array $diff): void
209208
$fromRange + $contextStartOffset + $contextEndOffset,
210209
$toStart - $contextStartOffset,
211210
$toRange + $contextStartOffset + $contextEndOffset,
212-
$output
211+
$output,
213212
);
214213
}
215214

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private function parseFileDiff(Diff $diff, array $lines): void
8383
(int) $match['start'],
8484
isset($match['startrange']) ? max(0, (int) $match['startrange']) : 1,
8585
(int) $match['end'],
86-
isset($match['endrange']) ? max(0, (int) $match['endrange']) : 1
86+
isset($match['endrange']) ? max(0, (int) $match['endrange']) : 1,
8787
);
8888

8989
$chunks[] = $chunk;

tests/ChunkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private function chunk(): Chunk
7474
4,
7575
[
7676
$this->line(),
77-
]
77+
],
7878
);
7979
}
8080

tests/DifferTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public function testArrayDiffs(): void
359359
-one
360360
+two
361361
',
362-
$this->differ->diff(['one'], ['two'])
362+
$this->differ->diff(['one'], ['two']),
363363
);
364364
}
365365

tests/Exception/ConfigurationExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testConstruct(): void
3535
'integer',
3636
new SplFileInfo(__FILE__),
3737
789,
38-
new BadMethodCallException(__METHOD__)
38+
new BadMethodCallException(__METHOD__),
3939
);
4040

4141
$this->assertSame('Option "test" must be integer, got "SplFileInfo".', $e->getMessage());

0 commit comments

Comments
 (0)