Skip to content
New issue

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

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

Already on GitHub? # to your account

Make the setting name more explicit #146

Merged
merged 1 commit into from
Oct 31, 2022
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
2 changes: 1 addition & 1 deletion e2e/scenario11/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing bamarni/composer-bin-plugin (dev-hash): Symlinking from ../..
Generating autoload files
[bamarni-bin] The setting "bamarni-bin.bin-links" will be set to "false" from 2.x onwards. If you wish to keep it to "true", you need to set it explicitly.
[bamarni-bin] The setting "extra.bamarni-bin.bin-links" will be set to "false" from 2.x onwards. If you wish to keep it to "true", you need to set it explicitly.
[bamarni-bin] The command is being forwarded.
[bamarni-bin] Checking namespace vendor-bin/ns1
Loading composer repositories with package information
Expand Down
10 changes: 5 additions & 5 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct(array $extra)
if (!is_bool($binLinks)) {
throw new InvalidBamarniComposerExtraConfig(
sprintf(
'Expected setting "%s.%s" to be a boolean value. Got "%s".',
'Expected setting "extra.%s.%s" to be a boolean value. Got "%s".',
self::EXTRA_CONFIG_KEY,
self::BIN_LINKS_ENABLED,
$getType($binLinks)
Expand All @@ -84,7 +84,7 @@ public function __construct(array $extra)

if ($binLinks && !$binLinksSetExplicitly) {
$this->deprecations[] = sprintf(
'The setting "%s.%s" will be set to "false" from 2.x onwards. If you wish to keep it to "true", you need to set it explicitly.',
'The setting "extra.%s.%s" will be set to "false" from 2.x onwards. If you wish to keep it to "true", you need to set it explicitly.',
self::EXTRA_CONFIG_KEY,
self::BIN_LINKS_ENABLED
);
Expand All @@ -95,7 +95,7 @@ public function __construct(array $extra)
if (!is_string($targetDirectory)) {
throw new InvalidBamarniComposerExtraConfig(
sprintf(
'Expected setting "%s.%s" to be a string. Got "%s".',
'Expected setting "extra.%s.%s" to be a string. Got "%s".',
self::EXTRA_CONFIG_KEY,
self::TARGET_DIRECTORY,
$getType($targetDirectory)
Expand All @@ -108,7 +108,7 @@ public function __construct(array $extra)
if (!is_bool($forwardCommand)) {
throw new InvalidBamarniComposerExtraConfig(
sprintf(
'Expected setting "%s.%s" to be a boolean value. Got "%s".',
'Expected setting "extra.%s.%s" to be a boolean value. Got "%s".',
self::EXTRA_CONFIG_KEY,
self::FORWARD_COMMAND,
gettype($forwardCommand)
Expand All @@ -120,7 +120,7 @@ public function __construct(array $extra)

if (!$forwardCommand && !$forwardCommandSetExplicitly) {
$this->deprecations[] = sprintf(
'The setting "%s.%s" will be set to "true" from 2.x onwards. If you wish to keep it to "false", you need to set it explicitly.',
'The setting "extra.%s.%s" will be set to "true" from 2.x onwards. If you wish to keep it to "false", you need to set it explicitly.',
self::EXTRA_CONFIG_KEY,
self::FORWARD_COMMAND
);
Expand Down
12 changes: 6 additions & 6 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function test_it_can_be_instantiated(

public static function provideExtraConfig(): iterable
{
$binLinksEnabledDeprecationMessage = 'The setting "bamarni-bin.bin-links" will be set to "false" from 2.x onwards. If you wish to keep it to "true", you need to set it explicitly.';
$forwardCommandDeprecationMessage = 'The setting "bamarni-bin.forward-command" will be set to "true" from 2.x onwards. If you wish to keep it to "false", you need to set it explicitly.';
$binLinksEnabledDeprecationMessage = 'The setting "extra.bamarni-bin.bin-links" will be set to "false" from 2.x onwards. If you wish to keep it to "true", you need to set it explicitly.';
$forwardCommandDeprecationMessage = 'The setting "extra.bamarni-bin.forward-command" will be set to "true" from 2.x onwards. If you wish to keep it to "false", you need to set it explicitly.';

yield 'default values' => [
[],
Expand Down Expand Up @@ -110,7 +110,7 @@ public static function provideInvalidExtraConfig(): iterable
Config::BIN_LINKS_ENABLED => 'foo',
],
],
'Expected setting "bamarni-bin.bin-links" to be a boolean value. Got "string".',
'Expected setting "extra.bamarni-bin.bin-links" to be a boolean value. Got "string".',
];

yield 'non string target directory' => [
Expand All @@ -120,8 +120,8 @@ public static function provideInvalidExtraConfig(): iterable
],
],
function_exists('get_debug_type')
? 'Expected setting "bamarni-bin.target-directory" to be a string. Got "bool".'
: 'Expected setting "bamarni-bin.target-directory" to be a string. Got "boolean".',
? 'Expected setting "extra.bamarni-bin.target-directory" to be a string. Got "bool".'
: 'Expected setting "extra.bamarni-bin.target-directory" to be a string. Got "boolean".',
];

yield 'non bool forward command' => [
Expand All @@ -130,7 +130,7 @@ function_exists('get_debug_type')
Config::FORWARD_COMMAND => 'foo',
],
],
'Expected setting "bamarni-bin.forward-command" to be a boolean value. Got "string".',
'Expected setting "extra.bamarni-bin.forward-command" to be a boolean value. Got "string".',
];
}
}