Skip to content

[OptionsResolver] Remove deprecated code #41316

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

Merged
merged 1 commit into from
May 23, 2021
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 src/Symfony/Component/OptionsResolver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.0
---

* Remove `OptionsResolverIntrospector::getDeprecationMessage()`

5.3
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ public function getNormalizers(string $option): array
return ($this->get)('normalizers', $option, sprintf('No normalizer was set for the "%s" option.', $option));
}

/**
* @return string|\Closure
*
* @throws NoConfigurationException on no configured deprecation
*
* @deprecated since Symfony 5.1, use "getDeprecation()" instead.
*/
public function getDeprecationMessage(string $option)
{
trigger_deprecation('symfony/options-resolver', '5.1', 'The "%s()" method is deprecated, use "getDeprecation()" instead.', __METHOD__);

return $this->getDeprecation($option)['message'];
}

/**
* @throws NoConfigurationException on no configured deprecation
*/
Expand Down
15 changes: 1 addition & 14 deletions src/Symfony/Component/OptionsResolver/OptionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public function isNested(string $option): bool
* @param string $version The version of the package that introduced the deprecation
* @param string|\Closure $message The deprecation message to use
*/
public function setDeprecated(string $option/*, string $package, string $version, $message = 'The option "%name%" is deprecated.' */): self
public function setDeprecated(string $option, string $package, string $version, $message = 'The option "%name%" is deprecated.'): self
{
if ($this->locked) {
throw new AccessException('Options cannot be deprecated from a lazy option or normalizer.');
Expand All @@ -459,19 +459,6 @@ public function setDeprecated(string $option/*, string $package, string $version
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist, defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
}

$args = \func_get_args();

if (\func_num_args() < 3) {
trigger_deprecation('symfony/options-resolver', '5.1', 'The signature of method "%s()" requires 2 new arguments: "string $package, string $version", not defining them is deprecated.', __METHOD__);

$message = $args[1] ?? 'The option "%name%" is deprecated.';
$package = $version = '';
} else {
$package = $args[1];
$version = $args[2];
$message = $args[3] ?? 'The option "%name%" is deprecated.';
}

if (!\is_string($message) && !$message instanceof \Closure) {
throw new InvalidArgumentException(sprintf('Invalid type for deprecation message argument, expected string or \Closure, but got "%s".', get_debug_type($message)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,32 +215,6 @@ public function testGetNormalizersThrowsOnNotDefinedOption()
$debug->getNormalizers('foo');
}

/**
* @group legacy
*/
public function testGetDeprecationMessage()
{
$resolver = new OptionsResolver();
$resolver->setDefined('foo');
$resolver->setDeprecated('foo', 'The option "foo" is deprecated.');

$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('The option "foo" is deprecated.', $debug->getDeprecationMessage('foo'));
}

/**
* @group legacy
*/
public function testGetClosureDeprecationMessage()
{
$resolver = new OptionsResolver();
$resolver->setDefined('foo');
$resolver->setDeprecated('foo', $closure = function (Options $options, $value) {});

$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($closure, $debug->getDeprecationMessage('foo'));
}

public function testGetDeprecation()
{
$resolver = new OptionsResolver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function testFailIfSetDeprecatedFromLazyOption()
$this->resolver
->setDefault('bar', 'baz')
->setDefault('foo', function (Options $options) {
$options->setDeprecated('bar');
$options->setDeprecated('bar', 'vendor/package', '1.1');
})
->resolve()
;
Expand All @@ -461,7 +461,7 @@ public function testFailIfSetDeprecatedFromLazyOption()
public function testSetDeprecatedFailsIfUnknownOption()
{
$this->expectException(UndefinedOptionsException::class);
$this->resolver->setDeprecated('foo');
$this->resolver->setDeprecated('foo', 'vendor/package', '1.1');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these could be worth fixing in 5.2,PR welcome

}

public function testSetDeprecatedFailsIfInvalidDeprecationMessageType()
Expand Down Expand Up @@ -2492,19 +2492,6 @@ public function testInfoOnInvalidValue()
$this->resolver->resolve(['expires' => new \DateTime('-1 hour')]);
}

/**
* @group legacy
*/
public function testSetDeprecatedWithoutPackageAndVersion()
{
$this->expectDeprecation('Since symfony/options-resolver 5.1: The signature of method "Symfony\Component\OptionsResolver\OptionsResolver::setDeprecated()" requires 2 new arguments: "string $package, string $version", not defining them is deprecated.');

$this->resolver
->setDefined('foo')
->setDeprecated('foo')
;
}

public function testInvalidValueForPrototypeDefinition()
{
$this->expectException(InvalidOptionsException::class);
Expand Down