From 7b0b7865600bdc377c9b10641bd9e5768f4bd35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 7 Nov 2023 21:37:38 +0100 Subject: [PATCH 1/3] feat: Deprecate the metadata setting Closes #1152. --- doc/configuration.md | 5 +++++ src/Configuration/Configuration.php | 2 ++ tests/Configuration/ConfigurationTest.php | 7 ++++++- tests/Console/Command/CompileTest.php | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/configuration.md b/doc/configuration.md index e6d0943d8..b5819c319 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -813,6 +813,10 @@ This setting will be ignored if no [key][key] has been provided. ## Metadata (`metadata`) +!!! warning + + The metadata setting has been deprecated as of Box 4.6.0. See [#1152]. + The metadata (`any` default none) setting can be any value. This value will be stored as metadata that can be retrieved from the built PHAR ([Phar::getMetadata()][phar.getmetadata]). @@ -1070,3 +1074,4 @@ The short commit hash will only be used if no tag is available. [stub]: #stub [symfony-finder]: https://symfony.com/doc/current//components/finder.html [zlib-extension]: https://secure.php.net/manual/en/book.zlib.php +[#1152]: https://github.com/box-project/box/issues/1152 diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index d66a22361..e1314fbe2 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -1892,6 +1892,8 @@ private static function retrieveMetadata(stdClass $raw, ConfigurationLogger $log return null; } + $logger->addWarning('Using the "metadata" setting is deprecated and will be removed in 5.0.0.'); + $metadata = $raw->{self::METADATA_KEY}; return is_object($metadata) ? (array) $metadata : $metadata; diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index 1ddeeb2dc..adcb254cf 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -1136,7 +1136,12 @@ public function test_can_configure_metadata(): void self::assertSame(123, $this->config->getMetadata()); self::assertSame([], $this->config->getRecommendations()); - self::assertSame([], $this->config->getWarnings()); + self::assertSame( + [ + 'Using the "metadata" setting is deprecated and will be removed in 5.0.0.' + ], + $this->config->getWarnings(), + ); } public function test_a_recommendation_is_given_if_the_default_metadata_is_provided(): void diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index e70348813..ab409bd7c 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -282,6 +282,7 @@ public function test_it_can_build_a_phar_file(): void No recommendation found. ⚠️ 1 warning found: + - Using the "metadata" setting is deprecated and will be removed in 5.0.0. - Using an OpenSSL signature is deprecated and will be removed in 5.0.0. Please check https://github.com/box-project/box/blob/main/doc/phar-signing.md for alternatives. // PHAR: {$numberOfFiles} files (100B) @@ -899,6 +900,7 @@ public function test_it_can_build_a_phar_file_in_verbose_mode(): void No recommendation found. ⚠️ 1 warning found: + - Using the "metadata" setting is deprecated and will be removed in 5.0.0. - Using an OpenSSL signature is deprecated and will be removed in 5.0.0. Please check https://github.com/box-project/box/blob/main/doc/phar-signing.md for alternatives. // PHAR: {$expectedNumberOfFiles} files (100B) @@ -1029,6 +1031,7 @@ public function test_it_can_build_a_phar_file_in_very_verbose_mode(): void No recommendation found. ⚠️ 1 warning found: + - Using the "metadata" setting is deprecated and will be removed in 5.0.0. - Using an OpenSSL signature is deprecated and will be removed in 5.0.0. Please check https://github.com/box-project/box/blob/main/doc/phar-signing.md for alternatives. // PHAR: {$expectedNumberOfFiles} files (100B) From 367d7c5e4b7d618e6060cf1396e13b20aaa79a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Wed, 8 Nov 2023 09:31:11 +0100 Subject: [PATCH 2/3] fix typo --- tests/Console/Command/CompileTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index ab409bd7c..a7944fe59 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -281,7 +281,7 @@ public function test_it_can_build_a_phar_file(): void * Done. No recommendation found. - ⚠️ 1 warning found: + ⚠️ 2 warnings found: - Using the "metadata" setting is deprecated and will be removed in 5.0.0. - Using an OpenSSL signature is deprecated and will be removed in 5.0.0. Please check https://github.com/box-project/box/blob/main/doc/phar-signing.md for alternatives. @@ -899,7 +899,7 @@ public function test_it_can_build_a_phar_file_in_verbose_mode(): void * Done. No recommendation found. - ⚠️ 1 warning found: + ⚠️ 2 warnings found: - Using the "metadata" setting is deprecated and will be removed in 5.0.0. - Using an OpenSSL signature is deprecated and will be removed in 5.0.0. Please check https://github.com/box-project/box/blob/main/doc/phar-signing.md for alternatives. @@ -1030,7 +1030,7 @@ public function test_it_can_build_a_phar_file_in_very_verbose_mode(): void * Done. No recommendation found. - ⚠️ 1 warning found: + ⚠️ 2 warnings found: - Using the "metadata" setting is deprecated and will be removed in 5.0.0. - Using an OpenSSL signature is deprecated and will be removed in 5.0.0. Please check https://github.com/box-project/box/blob/main/doc/phar-signing.md for alternatives. @@ -2826,7 +2826,7 @@ public function test_it_displays_recommendations_and_warnings(): void 💡 1 recommendation found: - The "check-requirements" setting can be omitted since is set to its default value - ⚠️ 1 warning found: + ⚠️ 2 warnings found: - The requirement checker could not be used because the composer.json and composer.lock file could not be found. // PHAR: 1 file (100B) From fa631daa7767a6442cbef4aa3f0a2a5db075392a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 9 Nov 2023 23:14:34 +0100 Subject: [PATCH 3/3] fix --- tests/Configuration/ConfigurationTest.php | 2 +- tests/Console/Command/CompileTest.php | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index 133439305..811486203 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -1138,7 +1138,7 @@ public function test_can_configure_metadata(): void self::assertSame([], $this->config->getRecommendations()); self::assertSame( [ - 'Using the "metadata" setting is deprecated and will be removed in 5.0.0.' + 'Using the "metadata" setting is deprecated and will be removed in 5.0.0.', ], $this->config->getWarnings(), ); diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index 626f1c32b..ef4fa1d21 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -575,7 +575,6 @@ public function test_it_can_build_a_phar_with_complete_mapping(): void 'map' => [ ['a/deep/test/directory' => 'sub'], ], - 'metadata' => ['rand' => $rand = random_int(0, mt_getrandmax())], 'output' => 'test.phar', ], ), @@ -627,10 +626,6 @@ public function test_it_can_build_a_phar_with_complete_mapping(): void > Generated by Humbug Box {$version}. > > @link https://github.com/humbug/box - ? Setting metadata - - array ( - 'rand' => {$rand}, - ) ? Dumping the Composer autoloader ? Removing the Composer dump artefacts ? No compression @@ -686,12 +681,6 @@ public function test_it_can_build_a_phar_with_complete_mapping(): void self::assertSame($expectedStub, $actualStub); - self::assertSame( - ['rand' => $rand], - $phar->getMetadata(), - 'Expected PHAR metadata to be set', - ); - $expectedFiles = [ '/one/', '/one/test.php', @@ -2826,7 +2815,7 @@ public function test_it_displays_recommendations_and_warnings(): void 💡 1 recommendation found: - The "check-requirements" setting can be omitted since is set to its default value - ⚠️ 2 warnings found: + ⚠️ 1 warning found: - The requirement checker could not be used because the composer.json and composer.lock file could not be found. // PHAR: 1 file (100B)