Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Deprecate the metadata setting #1155

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading