Skip to content

Commit

Permalink
feat: Deprecate the metadata setting (#1155)
Browse files Browse the repository at this point in the history
Closes #1152.
  • Loading branch information
theofidry authored Nov 9, 2023
1 parent 39403a7 commit 1d08985
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
5 changes: 5 additions & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).

Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion tests/Configuration/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 6 additions & 14 deletions tests/Console/Command/CompileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ public function test_it_can_build_a_phar_file(): void
* Done.
No recommendation found.
⚠️ <warning>1 warning found:</warning>
⚠️ <warning>2 warnings found:</warning>
- 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)
Expand Down Expand Up @@ -574,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',
],
),
Expand Down Expand Up @@ -626,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
Expand Down Expand Up @@ -685,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',
Expand Down Expand Up @@ -898,7 +888,8 @@ public function test_it_can_build_a_phar_file_in_verbose_mode(): void
* Done.
No recommendation found.
⚠️ <warning>1 warning found:</warning>
⚠️ <warning>2 warnings found:</warning>
- 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)
Expand Down Expand Up @@ -1028,7 +1019,8 @@ public function test_it_can_build_a_phar_file_in_very_verbose_mode(): void
* Done.
No recommendation found.
⚠️ <warning>1 warning found:</warning>
⚠️ <warning>2 warnings found:</warning>
- 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)
Expand Down

0 comments on commit 1d08985

Please sign in to comment.