From c8af3578809d30017afb37029ee11872c14f1931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:33:02 +0200 Subject: [PATCH] refactor: Rename DiffMode::LIST to ::FILE_NAME (#1055) --- src/Console/Command/Diff.php | 6 +++--- src/Phar/DiffMode.php | 2 +- src/Phar/PharDiff.php | 2 +- tests/Console/Command/DiffTest.php | 18 +++++++++--------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Console/Command/Diff.php b/src/Console/Command/Diff.php index 8be1e90cd..b5523f118 100644 --- a/src/Console/Command/Diff.php +++ b/src/Console/Command/Diff.php @@ -101,7 +101,7 @@ public function getConfiguration(): Configuration DiffMode::values(), ), ), - DiffMode::LIST->value, + DiffMode::FILE_NAME->value, ), new InputOption( self::CHECK_OPTION, @@ -210,11 +210,11 @@ private static function getDiffMode(IO $io): DiffMode '⚠️ Using the option "%s" is deprecated. Use "--%s=%s" instead.', self::LIST_FILES_DIFF_OPTION, self::DIFF_OPTION, - DiffMode::LIST->value, + DiffMode::FILE_NAME->value, ), ); - return DiffMode::LIST; + return DiffMode::FILE_NAME; } return DiffMode::from($io->getOption(self::DIFF_OPTION)->asNonEmptyString()); diff --git a/src/Phar/DiffMode.php b/src/Phar/DiffMode.php index bad3736b0..f2bc081e0 100644 --- a/src/Phar/DiffMode.php +++ b/src/Phar/DiffMode.php @@ -18,7 +18,7 @@ enum DiffMode: string { - case LIST = 'list'; + case FILE_NAME = 'file-name'; case GIT = 'git'; case GNU = 'gnu'; diff --git a/src/Phar/PharDiff.php b/src/Phar/PharDiff.php index 4ccc5b90d..2638f05da 100644 --- a/src/Phar/PharDiff.php +++ b/src/Phar/PharDiff.php @@ -71,7 +71,7 @@ public function equals(): bool */ public function diff(DiffMode $mode): null|string|array { - if (DiffMode::LIST === $mode) { + if (DiffMode::FILE_NAME === $mode) { return $this->listDiff(); } diff --git a/tests/Console/Command/DiffTest.php b/tests/Console/Command/DiffTest.php index 794aba55b..15f3f2e1c 100644 --- a/tests/Console/Command/DiffTest.php +++ b/tests/Console/Command/DiffTest.php @@ -100,7 +100,7 @@ public function test_it_can_display_the_list_diff_of_two_phar_files(): void ); $expectedOutput = <<<'OUTPUT' - ⚠️ Using the option "list-diff" is deprecated. Use "--diff=list" instead. + ⚠️ Using the option "list-diff" is deprecated. Use "--diff=file-name" instead. // Comparing the two archives... @@ -133,7 +133,7 @@ public function test_it_can_display_the_git_diff_of_two_phar_files(): void ); $expectedOutput = <<<'OUTPUT' - ⚠️ Using the option "list-diff" is deprecated. Use "--diff=list" instead. + ⚠️ Using the option "list-diff" is deprecated. Use "--diff=file-name" instead. // Comparing the two archives... @@ -300,15 +300,15 @@ public function test_it_does_not_swallow_exceptions_in_debug_mode(): void public static function diffPharsProvider(): iterable { - foreach (self::listDiffPharsProvider() as $label => $set) { + foreach (self::fileNameDiffPharsProvider() as $label => $set) { array_splice( $set, 2, 0, - [DiffMode::LIST], + [DiffMode::FILE_NAME], ); - yield '[list] '.$label => $set; + yield '[file-name] '.$label => $set; } foreach (self::gitDiffPharsProvider() as $label => $set) { @@ -398,9 +398,9 @@ private static function commonDiffPharsProvider(DiffMode $diffMode): iterable ]; } - private static function listDiffPharsProvider(): iterable + private static function fileNameDiffPharsProvider(): iterable { - yield from self::commonDiffPharsProvider(DiffMode::LIST); + yield from self::commonDiffPharsProvider(DiffMode::FILE_NAME); yield 'different files' => [ self::FIXTURES_DIR.'/simple-phar-foo.phar', @@ -436,7 +436,7 @@ private static function listDiffPharsProvider(): iterable Metadata: None Contents: 1 file (6.64KB) - // Comparing the two archives contents (list diff)... + // Comparing the two archives contents (file-name diff)... --- Files present in "simple-phar-foo.phar" but not in "simple-phar-bar.phar" +++ Files present in "simple-phar-bar.phar" but not in "simple-phar-foo.phar" @@ -487,7 +487,7 @@ private static function listDiffPharsProvider(): iterable -Contents: 1 file (6.64KB) +Contents: 1 file (6.61KB) - // Comparing the two archives contents (list diff)... + // Comparing the two archives contents (file-name diff)... No difference could be observed with this mode.