diff --git a/src/Symfony/Component/OptionsResolver/CHANGELOG.md b/src/Symfony/Component/OptionsResolver/CHANGELOG.md index 84c45946a9b72..791a402faaf3a 100644 --- a/src/Symfony/Component/OptionsResolver/CHANGELOG.md +++ b/src/Symfony/Component/OptionsResolver/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.0 +--- + + * Remove `OptionsResolverIntrospector::getDeprecationMessage()` + 5.3 --- diff --git a/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php b/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php index 95909f32e48e6..7374519dd336b 100644 --- a/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php +++ b/src/Symfony/Component/OptionsResolver/Debug/OptionsResolverIntrospector.php @@ -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 */ diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index a8ae153f46ee5..60787289041be 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -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.'); @@ -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))); } diff --git a/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php index 17d38bf9ad231..404d29d0a38bc 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php @@ -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(); diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index 3c36225e183a6..596f19a80dcab 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -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() ; @@ -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'); } public function testSetDeprecatedFailsIfInvalidDeprecationMessageType() @@ -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);