diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3aa8d0ea..2b7cd2ce 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -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', ], @@ -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' => [ @@ -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, @@ -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, @@ -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, @@ -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, @@ -132,10 +142,10 @@ '@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, @@ -143,7 +153,6 @@ '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, @@ -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, @@ -171,15 +180,17 @@ '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, @@ -187,6 +198,7 @@ 'non_printable_character' => true, 'normalize_index_brace' => true, 'object_operator_without_whitespace' => true, + 'octal_notation' => true, 'operator_linebreak' => [ 'only_booleans' => true, 'position' => 'end', @@ -217,9 +229,9 @@ ], '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' => [ @@ -227,6 +239,7 @@ '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', @@ -250,6 +263,7 @@ 'uses', ], ], + 'phpdoc_param_order' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, 'phpdoc_separation' => true, @@ -257,7 +271,7 @@ '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']], @@ -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, @@ -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' => [ diff --git a/src/Exception/ConfigurationException.php b/src/Exception/ConfigurationException.php index 85f066c2..6b8c79c4 100644 --- a/src/Exception/ConfigurationException.php +++ b/src/Exception/ConfigurationException.php @@ -28,10 +28,10 @@ public function __construct( 'Option "%s" must be %s, got "%s".', $option, $expected, - is_object($value) ? $value::class : (null === $value ? '' : gettype($value) . '#' . $value) + is_object($value) ? $value::class : (null === $value ? '' : gettype($value) . '#' . $value), ), $code, - $previous + $previous, ); } } diff --git a/src/MemoryEfficientLongestCommonSubsequenceCalculator.php b/src/MemoryEfficientLongestCommonSubsequenceCalculator.php index a46de07d..b9846c37 100644 --- a/src/MemoryEfficientLongestCommonSubsequenceCalculator.php +++ b/src/MemoryEfficientLongestCommonSubsequenceCalculator.php @@ -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), ); } @@ -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 { diff --git a/src/Output/StrictUnifiedDiffOutputBuilder.php b/src/Output/StrictUnifiedDiffOutputBuilder.php index 3eb7428d..a2a73b67 100644 --- a/src/Output/StrictUnifiedDiffOutputBuilder.php +++ b/src/Output/StrictUnifiedDiffOutputBuilder.php @@ -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']; @@ -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; @@ -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, @@ -261,7 +261,7 @@ private function writeDiffHunks($output, array $diff): void $fromRange + $contextStartOffset + $contextEndOffset, $toStart - $contextStartOffset, $toRange + $contextStartOffset + $contextEndOffset, - $output + $output, ); } @@ -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 - //} + // } } } diff --git a/src/Output/UnifiedDiffOutputBuilder.php b/src/Output/UnifiedDiffOutputBuilder.php index 1483b3af..683ab1b6 100644 --- a/src/Output/UnifiedDiffOutputBuilder.php +++ b/src/Output/UnifiedDiffOutputBuilder.php @@ -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; @@ -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; } @@ -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; @@ -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, @@ -209,7 +208,7 @@ private function writeDiffHunks($output, array $diff): void $fromRange + $contextStartOffset + $contextEndOffset, $toStart - $contextStartOffset, $toRange + $contextStartOffset + $contextEndOffset, - $output + $output, ); } diff --git a/src/Parser.php b/src/Parser.php index 6232c957..9293fc91 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -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; diff --git a/tests/ChunkTest.php b/tests/ChunkTest.php index 5087a146..4a9c064e 100644 --- a/tests/ChunkTest.php +++ b/tests/ChunkTest.php @@ -74,7 +74,7 @@ private function chunk(): Chunk 4, [ $this->line(), - ] + ], ); } diff --git a/tests/DifferTest.php b/tests/DifferTest.php index fcbcca08..2306c134 100644 --- a/tests/DifferTest.php +++ b/tests/DifferTest.php @@ -359,7 +359,7 @@ public function testArrayDiffs(): void -one +two ', - $this->differ->diff(['one'], ['two']) + $this->differ->diff(['one'], ['two']), ); } diff --git a/tests/Exception/ConfigurationExceptionTest.php b/tests/Exception/ConfigurationExceptionTest.php index 5218c361..526d6d36 100644 --- a/tests/Exception/ConfigurationExceptionTest.php +++ b/tests/Exception/ConfigurationExceptionTest.php @@ -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()); diff --git a/tests/Output/AbstractChunkOutputBuilderTest.php b/tests/Output/AbstractChunkOutputBuilderTest.php index c5c9a201..b7075b96 100644 --- a/tests/Output/AbstractChunkOutputBuilderTest.php +++ b/tests/Output/AbstractChunkOutputBuilderTest.php @@ -140,7 +140,7 @@ public function getChunks(array $diff, $lineThreshold) $this->assertSame( $expected, - $output->getChunks((new Differ(new UnifiedDiffOutputBuilder))->diffToArray($from, $to), $lineThreshold) + $output->getChunks((new Differ(new UnifiedDiffOutputBuilder))->diffToArray($from, $to), $lineThreshold), ); } } diff --git a/tests/Output/Integration/StrictUnifiedDiffOutputBuilderIntegrationTest.php b/tests/Output/Integration/StrictUnifiedDiffOutputBuilderIntegrationTest.php index eea19345..f91e6fd4 100644 --- a/tests/Output/Integration/StrictUnifiedDiffOutputBuilderIntegrationTest.php +++ b/tests/Output/Integration/StrictUnifiedDiffOutputBuilderIntegrationTest.php @@ -171,7 +171,7 @@ public function testIntegrationDiffOutputBuilderVersusDiffCommand(string $diff, [ 'from' => $this->fileFrom, 'to' => $this->fileTo, - ] + ], ); $this->assertSame(1, $p->getExitCode()); // note: Process assumes exit code 0 for `isSuccessful`, however `diff` uses the exit code `1` for success with diff @@ -207,7 +207,7 @@ private function doIntegrationTestGitApply(string $diff, string $from, string $t [ 'dir' => $this->dir, 'patch' => $this->filePatch, - ] + ], ); $this->assertProcessSuccessful($p); @@ -229,7 +229,7 @@ private function doIntegrationTestPatch(string $diff, string $from, string $to): [ 'from' => $this->fileFrom, 'patch' => $this->filePatch, - ] + ], ); $this->assertProcessSuccessful($p); @@ -237,7 +237,7 @@ private function doIntegrationTestPatch(string $diff, string $from, string $to): $this->assertStringEqualsFile( $this->fileFrom, $to, - sprintf('Patch command "%s".', $p->getCommandLine()) + sprintf('Patch command "%s".', $p->getCommandLine()), ); } @@ -250,8 +250,8 @@ private function assertProcessSuccessful(Process $p): void $p->getCommandLine(), $p->getOutput(), $p->getErrorOutput(), - $p->getExitCode() - ) + $p->getExitCode(), + ), ); } diff --git a/tests/Output/Integration/UnifiedDiffOutputBuilderIntegrationTest.php b/tests/Output/Integration/UnifiedDiffOutputBuilderIntegrationTest.php index f686e107..95bb180c 100644 --- a/tests/Output/Integration/UnifiedDiffOutputBuilderIntegrationTest.php +++ b/tests/Output/Integration/UnifiedDiffOutputBuilderIntegrationTest.php @@ -20,7 +20,7 @@ use function preg_split; use function realpath; use function sprintf; -use function strpos; +use function str_contains; use function unlink; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -49,9 +49,9 @@ public static function provideDiffWithLineNumbers(): array UnifiedDiffOutputBuilderDataProvider::provideDiffWithLineNumbers(), static function ($key) { - return !is_string($key) || false === strpos($key, 'non_patch_compat'); + return !is_string($key) || !str_contains($key, 'non_patch_compat'); }, - ARRAY_FILTER_USE_KEY + ARRAY_FILTER_USE_KEY, ); } @@ -97,7 +97,7 @@ private function doIntegrationTestPatch(string $diff, string $from, string $to): [ 'from' => $this->fileFrom, 'patch' => $this->filePatch, - ] + ], ); $this->assertProcessSuccessful($p); @@ -105,7 +105,7 @@ private function doIntegrationTestPatch(string $diff, string $from, string $to): $this->assertStringEqualsFile( $this->fileFrom, $to, - sprintf('Patch command "%s".', $p->getCommandLine()) + sprintf('Patch command "%s".', $p->getCommandLine()), ); } @@ -125,7 +125,7 @@ private function doIntegrationTestGitApply(string $diff, string $from, string $t [ 'dir' => $this->dir, 'patch' => $this->filePatch, - ] + ], ); $this->assertProcessSuccessful($p); @@ -140,8 +140,8 @@ private function assertProcessSuccessful(Process $p): void $p->getCommandLine(), $p->getOutput(), $p->getErrorOutput(), - $p->getExitCode() - ) + $p->getExitCode(), + ), ); } diff --git a/tests/Output/StrictUnifiedDiffOutputBuilderTest.php b/tests/Output/StrictUnifiedDiffOutputBuilderTest.php index 38617cd6..0655a3fd 100644 --- a/tests/Output/StrictUnifiedDiffOutputBuilderTest.php +++ b/tests/Output/StrictUnifiedDiffOutputBuilderTest.php @@ -32,17 +32,11 @@ final class StrictUnifiedDiffOutputBuilderTest extends TestCase { use UnifiedDiffAssertTrait; - /** - * @inheritDoc - */ public static function provideOutputBuildingCases(): array { return StrictUnifiedDiffOutputBuilderDataProvider::provideOutputBuildingCases(); } - /** - * @inheritDoc - */ public static function provideSample(): array { return StrictUnifiedDiffOutputBuilderDataProvider::provideSample(); @@ -523,9 +517,6 @@ public function testSample(string $expected, string $from, string $to, array $op $this->assertSame($expected, $diff); } - /** - * @inheritDoc - */ public function assertValidDiffFormat(string $diff): void { $this->assertValidUnifiedDiffFormat($diff); @@ -571,13 +562,13 @@ public function testReUseBuilder(): void -B +X ', - $diff + $diff, ); $diff = $differ->diff("A\n", "A\n"); $this->assertSame( '', - $diff + $diff, ); } @@ -590,7 +581,7 @@ public function testEmptyDiff(): void $this->assertSame( '', - $builder->getDiff([]) + $builder->getDiff([]), ); } diff --git a/tests/Output/UnifiedDiffOutputBuilderTest.php b/tests/Output/UnifiedDiffOutputBuilderTest.php index 5f22b620..f4ec7e5e 100644 --- a/tests/Output/UnifiedDiffOutputBuilderTest.php +++ b/tests/Output/UnifiedDiffOutputBuilderTest.php @@ -75,7 +75,7 @@ public function testCustomHeaderCanBeUsed(string $expected, string $from, string $this->assertSame( $expected, - $differ->diff($from, $to) + $differ->diff($from, $to), ); } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 11d9560a..c5dbbf7c 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -150,7 +150,6 @@ public function testParseWithRemovedLines(): void $this->assertContainsOnlyInstancesOf(Line::class, $lines); $this->assertCount(2, $lines); - /** @var Line $line */ $line = $lines[0]; $this->assertSame('A', $line->content()); $this->assertSame(Line::UNCHANGED, $line->type()); @@ -182,7 +181,6 @@ public function testParseDiffForMulitpleFiles(): void $diffs = $this->parser->parse($content); $this->assertCount(2, $diffs); - /** @var Diff $diff */ $diff = $diffs[0]; $this->assertSame('a/Test.txt', $diff->from()); $this->assertSame('b/Test.txt', $diff->to()); diff --git a/tests/Utils/FileUtils.php b/tests/Utils/FileUtils.php index 09954dc7..5613d784 100644 --- a/tests/Utils/FileUtils.php +++ b/tests/Utils/FileUtils.php @@ -27,8 +27,8 @@ public static function getFileContent(string $file): string sprintf( 'Failed to read content of file "%s".%s', $file, - $error ? ' ' . $error['message'] : '' - ) + $error ? ' ' . $error['message'] : '', + ), ); } diff --git a/tests/Utils/UnifiedDiffAssertTrait.php b/tests/Utils/UnifiedDiffAssertTrait.php index a79dbaab..f3feb46f 100644 --- a/tests/Utils/UnifiedDiffAssertTrait.php +++ b/tests/Utils/UnifiedDiffAssertTrait.php @@ -15,8 +15,8 @@ use function preg_match; use function preg_split; use function sprintf; +use function str_starts_with; use function strlen; -use function strpos; use function substr; use RuntimeException; use UnexpectedValueException; @@ -52,8 +52,8 @@ public function assertValidUnifiedDiffFormat(string $diff): void $this->unifiedDiffAssertLinePrefix($lines[0], 'Line 1.'); $this->unifiedDiffAssertLinePrefix($lines[1], 'Line 2.'); - if ('---' === substr($lines[0], 0, 3)) { - if ('+++' !== substr($lines[1], 0, 3)) { + if (str_starts_with($lines[0], '---')) { + if (!str_starts_with($lines[1], '+++')) { throw new UnexpectedValueException(sprintf("Line 1 indicates a header, so line 2 must start with \"+++\".\nLine 1: \"%s\"\nLine 2: \"%s\".", $lines[0], $lines[1])); } @@ -211,7 +211,7 @@ private function unifiedDiffAssertStrLength(string $line, int $min, string $mess */ private function unifiedDiffAssertHeaderLine(string $line, string $start, string $message): void { - if (0 !== strpos($line, $start)) { + if (!str_starts_with($line, $start)) { throw new UnexpectedValueException(sprintf('Expected header line to start with "%s", got "%s". %s', $start . ' ', $line, $message)); } @@ -219,7 +219,7 @@ private function unifiedDiffAssertHeaderLine(string $line, string $start, string $match = preg_match( "/^([^\t]*)(?:[\t]([\\S].*[\\S]))?\n$/", substr($line, 4), // 4 === string length of "+++ " / "--- " - $matches + $matches, ); if (1 !== $match) { @@ -239,7 +239,7 @@ private function unifiedDiffAssertHeaderDate(string $date, string $message): voi $match = preg_match( '/^([\d]{4})-([01]?[\d])-([0123]?[\d])(:? [\d]{1,2}:[\d]{1,2}(?::[\d]{1,2}(:?\.[\d]+)?)?(?: ([\+\-][\d]{4}))?)?$/', $date, - $matches + $matches, ); if (1 !== $match || ($matchesCount = count($matches)) < 4) { @@ -259,8 +259,8 @@ private function unifiedDiffAssertHunkHeader(string $line, string $message): arr sprintf( 'Hunk header line does not match expected pattern, got "%s". %s', $line, - $message - ) + $message, + ), ); } diff --git a/tests/Utils/UnifiedDiffAssertTraitIntegrationTest.php b/tests/Utils/UnifiedDiffAssertTraitIntegrationTest.php index 840e1848..1ec94ae1 100644 --- a/tests/Utils/UnifiedDiffAssertTraitIntegrationTest.php +++ b/tests/Utils/UnifiedDiffAssertTraitIntegrationTest.php @@ -99,7 +99,7 @@ public function testValidPatches(string $fileFrom, string $fileTo): void 'from' => realpath($fileFrom), 'to' => realpath($fileTo), 'patch' => $this->filePatch, - ] + ], ); $exitCode = $p->getExitCode(); @@ -119,8 +119,8 @@ public function testValidPatches(string $fileFrom, string $fileTo): void $p->getCommandLine(), $p->getOutput(), $p->getErrorOutput(), - $p->getExitCode() - ) + $p->getExitCode(), + ), ); $this->assertValidUnifiedDiffFormat(FileUtils::getFileContent($this->filePatch)); diff --git a/tests/Utils/UnifiedDiffAssertTraitTest.php b/tests/Utils/UnifiedDiffAssertTraitTest.php index ef681b97..42b4fc70 100644 --- a/tests/Utils/UnifiedDiffAssertTraitTest.php +++ b/tests/Utils/UnifiedDiffAssertTraitTest.php @@ -99,7 +99,7 @@ public function testInvalidStartHeader3(): void -A +B " . ' -' +', ); } @@ -115,7 +115,7 @@ public function testInvalidStartHeader4(): void -A +B ' . ' -' +', ); } @@ -131,7 +131,7 @@ public function testInvalidLine1(): void -Z 1 +U -' +', ); } @@ -146,7 +146,7 @@ public function testInvalidLine2(): void @@ -8 +8 @@ -' +', ); } @@ -161,7 +161,7 @@ public function testHunkInvalidFormat(): void @@ INVALID -1,1 +1,1 @@ -Z +U -' +', ); } @@ -179,7 +179,7 @@ public function testHunkOverlapFrom(): void @@ -7,1 +9,1 @@ -Z +U -' +', ); } @@ -197,7 +197,7 @@ public function testHunkOverlapTo(): void @@ -17,1 +7,1 @@ -Z +U -' +', ); } @@ -213,7 +213,7 @@ public function testExpectHunk1(): void -Z +U +O -' +', ); } @@ -229,7 +229,7 @@ public function testExpectHunk2(): void ' . ' ' . ' @@ -38,12 +48,12 @@ -' +', ); } @@ -247,7 +247,7 @@ public function testMisplacedLineAfterComments1(): void +U \ No newline at end of file +A -' +', ); } @@ -264,7 +264,7 @@ public function testMisplacedLineAfterComments2(): void \ No newline at end of file \ No newline at end of file \ No newline at end of file -' +', ); } @@ -281,7 +281,7 @@ public function testMisplacedLineAfterComments3(): void \ No newline at end of file \ No newline at end of file +A -' +', ); } @@ -292,7 +292,7 @@ public function testMisplacedComment(): void $this->assertValidUnifiedDiffFormat( '\ No newline at end of file -' +', ); } @@ -310,7 +310,7 @@ public function testUnexpectedDuplicateNoNewLineEOF(): void \ No newline at end of file ' . ' \ No newline at end of file -' +', ); } @@ -327,7 +327,7 @@ public function testFromAfterClose(): void \ No newline at end of file -A \ No newline at end of file -' +', ); } @@ -344,7 +344,7 @@ public function testSameAfterFromClose(): void \ No newline at end of file A \ No newline at end of file -' +', ); } @@ -361,7 +361,7 @@ public function testToAfterClose(): void \ No newline at end of file +A \ No newline at end of file -' +', ); } @@ -378,7 +378,7 @@ public function testSameAfterToClose(): void \ No newline at end of file A \ No newline at end of file -' +', ); } @@ -394,7 +394,7 @@ public function testUnexpectedEOFFromMissingLines(): void -A +B ' . ' -' +', ); } @@ -410,7 +410,7 @@ public function testUnexpectedEOFToMissingLines(): void -A +B ' . ' -' +', ); } @@ -426,7 +426,7 @@ public function testUnexpectedEOFBothFromAndToMissingLines(): void -A +B ' . ' -' +', ); } }