Skip to content

Commit

Permalink
Merge branch '5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 24, 2023
2 parents 059ddc5 + a4c3148 commit e16843d
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 107 deletions.
66 changes: 45 additions & 21 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => [
'operators' => [
'*=' => 'align_single_space_minimal',
'+=' => 'align_single_space_minimal',
'-=' => 'align_single_space_minimal',
'/=' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
],
Expand Down Expand Up @@ -57,6 +61,14 @@
'yield_from',
],
],
'blank_lines_before_namespace' => [
'max_line_breaks' => 1,
'min_line_breaks' => 0,
],
'braces_position' => [
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
],
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => [
Expand All @@ -70,15 +82,11 @@
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'compact_nullable_typehint' => true,
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => true,
'control_structure_braces' => true,
'control_structure_continuation_position' => true,
'curly_braces_position' => [
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => true,
Expand All @@ -94,7 +102,6 @@
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'get_class_to_class_keyword' => true,
'global_namespace_import' => [
'import_classes' => true,
Expand All @@ -106,9 +113,10 @@
'implode_call' => true,
'include' => true,
'increment_style' => [
'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
'style' => 'post',
],
'indentation_type' => true,
'integer_literal_case' => true,
'is_null' => true,
'lambda_not_used_import' => true,
'line_ending' => true,
Expand All @@ -122,6 +130,8 @@
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
],
'method_chaining_indentation' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
Expand All @@ -132,18 +142,17 @@
'@internal',
],
],
'native_function_type_declaration_casing' => true,
'new_with_braces' => [
'named_class' => false,
'native_type_declaration_casing' => true,
'new_with_parentheses' => [
'anonymous_class' => false,
'named_class' => false,
],
'no_alias_functions' => true,
'no_alias_language_construct_call' => true,
'no_alternative_syntax' => true,
'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
Expand All @@ -154,15 +163,15 @@
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'print'],
'no_multiple_statements_per_line' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiple_statements_per_line' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_space_around_double_colon' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
Expand All @@ -171,22 +180,25 @@
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => true,
'no_unneeded_braces' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unneeded_import_alias' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_concat_operator' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'no_useless_return' => true,
'no_useless_sprintf' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'octal_notation' => true,
'operator_linebreak' => [
'only_booleans' => true,
'position' => 'end',
Expand Down Expand Up @@ -217,16 +229,17 @@
],
'ordered_imports' => [
'imports_order' => [
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
'const',
'function',
'class',
]
],
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'ordered_traits' => true,
'ordered_types' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
Expand All @@ -250,14 +263,15 @@
'uses',
],
],
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_tag_casing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => true,
'phpdoc_to_comment' => false,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'meta']],
Expand All @@ -279,15 +293,20 @@
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_spacing' => true,
'single_quote' => true,
'single_space_around_construct' => true,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => true,
'spaces_inside_parentheses' => [
'space' => 'none',
],
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,
'static_lambda' => true,
'strict_param' => true,
'string_length_to_empty'=> true,
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
Expand All @@ -297,13 +316,18 @@
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'elements' => [
'arrays'
'arguments',
'arrays',
'match',
]
],
'trim_array_spaces' => true,
'types_spaces' => [
'space' => 'none',
'type_declaration_spaces' => [
'elements' => [
'function',
],
],
'types_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/ConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function __construct(
'Option "%s" must be %s, got "%s".',
$option,
$expected,
is_object($value) ? $value::class : (null === $value ? '<null>' : gettype($value) . '#' . $value)
is_object($value) ? $value::class : (null === $value ? '<null>' : gettype($value) . '#' . $value),
),
$code,
$previous
$previous,
);
}
}
8 changes: 6 additions & 2 deletions src/MemoryEfficientLongestCommonSubsequenceCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function calculate(array $from, array $to): array

return array_merge(
$this->calculate($fromStart, $toStart),
$this->calculate($fromEnd, $toEnd)
$this->calculate($fromEnd, $toEnd),
);
}

Expand All @@ -78,7 +78,11 @@ private function length(array $from, array $to): array
if ($from[$i] === $to[$j]) {
$current[$j + 1] = $prev[$j] + 1;
} else {
// don't use max() to avoid function call overhead
/**
* @noinspection PhpConditionCanBeReplacedWithMinMaxCallInspection
*
* We do not use max() here to avoid the function call overhead
*/
if ($current[$j] > $prev[$j + 1]) {
$current[$j + 1] = $current[$j];
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/Output/StrictUnifiedDiffOutputBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(array $options = [])
$options['fromFile'],
null === $options['fromFileDate'] ? '' : "\t" . $options['fromFileDate'],
$options['toFile'],
null === $options['toFileDate'] ? '' : "\t" . $options['toFileDate']
null === $options['toFileDate'] ? '' : "\t" . $options['toFileDate'],
);

$this->collapseRanges = $options['collapseRanges'];
Expand Down Expand Up @@ -201,11 +201,11 @@ private function writeDiffHunks($output, array $diff): void
$fromRange - $cutOff + $contextStartOffset + $this->contextLines,
$toStart - $contextStartOffset,
$toRange - $cutOff + $contextStartOffset + $this->contextLines,
$output
$output,
);

$fromStart += $fromRange;
$toStart += $toRange;
$toStart += $toRange;

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

$fromRange -= $sameCount;
$toRange -= $sameCount;
$toRange -= $sameCount;

$this->writeHunk(
$diff,
Expand All @@ -261,7 +261,7 @@ private function writeDiffHunks($output, array $diff): void
$fromRange + $contextStartOffset + $contextEndOffset,
$toStart - $contextStartOffset,
$toRange + $contextStartOffset + $contextEndOffset,
$output
$output,
);
}

Expand Down Expand Up @@ -302,11 +302,11 @@ private function writeHunk(
$this->changed = true;
fwrite($output, $diff[$i][0]);
}
//} elseif ($diff[$i][1] === Differ::DIFF_LINE_END_WARNING) { // custom comment inserted by PHPUnit/diff package
// } elseif ($diff[$i][1] === Differ::DIFF_LINE_END_WARNING) { // custom comment inserted by PHPUnit/diff package
// skip
//} else {
// } else {
// unknown/invalid
//}
// }
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/Output/UnifiedDiffOutputBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use function min;
use function str_ends_with;
use function stream_get_contents;
use function strlen;
use function substr;
use SebastianBergmann\Diff\Differ;

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

return 0 !== strlen($diff) && "\n" !== $last && "\r" !== $last
return '' !== $diff && "\n" !== $last && "\r" !== $last
? $diff . "\n"
: $diff;
}
Expand Down Expand Up @@ -151,11 +150,11 @@ private function writeDiffHunks($output, array $diff): void
$fromRange - $cutOff + $contextStartOffset + $this->contextLines,
$toStart - $contextStartOffset,
$toRange - $cutOff + $contextStartOffset + $this->contextLines,
$output
$output,
);

$fromStart += $fromRange;
$toStart += $toRange;
$toStart += $toRange;

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

$fromRange -= $sameCount;
$toRange -= $sameCount;
$toRange -= $sameCount;

$this->writeHunk(
$diff,
Expand All @@ -209,7 +208,7 @@ private function writeDiffHunks($output, array $diff): void
$fromRange + $contextStartOffset + $contextEndOffset,
$toStart - $contextStartOffset,
$toRange + $contextStartOffset + $contextEndOffset,
$output
$output,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function parseFileDiff(Diff $diff, array $lines): void
(int) $match['start'],
isset($match['startrange']) ? max(0, (int) $match['startrange']) : 1,
(int) $match['end'],
isset($match['endrange']) ? max(0, (int) $match['endrange']) : 1
isset($match['endrange']) ? max(0, (int) $match['endrange']) : 1,
);

$chunks[] = $chunk;
Expand Down
2 changes: 1 addition & 1 deletion tests/ChunkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function chunk(): Chunk
4,
[
$this->line(),
]
],
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/DifferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public function testArrayDiffs(): void
-one
+two
',
$this->differ->diff(['one'], ['two'])
$this->differ->diff(['one'], ['two']),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/ConfigurationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testConstruct(): void
'integer',
new SplFileInfo(__FILE__),
789,
new BadMethodCallException(__METHOD__)
new BadMethodCallException(__METHOD__),
);

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

0 comments on commit e16843d

Please sign in to comment.