diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index 75ef8bc4416c9..bc34ee5aeb997 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.0 +--- + + * Remove `BaseNode::getDeprecationMessage()` + 5.3.0 ----- diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index db1955e96a5e4..d5db600894469 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -205,29 +205,8 @@ public function setRequired(bool $boolean) * You can use %node% and %path% placeholders in your message to display, * respectively, the node name and its complete path */ - public function setDeprecated(?string $package/*, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */) + public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.') { - $args = \func_get_args(); - - if (\func_num_args() < 2) { - trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__); - - if (!isset($args[0])) { - trigger_deprecation('symfony/config', '5.1', 'Passing a null message to un-deprecate a node is deprecated.'); - - $this->deprecation = []; - - return; - } - - $message = (string) $args[0]; - $package = $version = ''; - } else { - $package = (string) $args[0]; - $version = (string) $args[1]; - $message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.'); - } - $this->deprecation = [ 'package' => $package, 'version' => $version, @@ -281,23 +260,6 @@ public function isDeprecated() return (bool) $this->deprecation; } - /** - * Returns the deprecated message. - * - * @param string $node the configuration node name - * @param string $path the path of the node - * - * @return string - * - * @deprecated since Symfony 5.1, use "getDeprecation()" instead. - */ - public function getDeprecationMessage(string $node, string $path) - { - trigger_deprecation('symfony/config', '5.1', 'The "%s()" method is deprecated, use "getDeprecation()" instead.', __METHOD__); - - return $this->getDeprecation($node, $path)['message']; - } - /** * @param string $node The configuration node name * @param string $path The path of the node @@ -305,9 +267,9 @@ public function getDeprecationMessage(string $node, string $path) public function getDeprecation(string $node, string $path): array { return [ - 'package' => $this->deprecation['package'] ?? '', - 'version' => $this->deprecation['version'] ?? '', - 'message' => strtr($this->deprecation['message'] ?? '', ['%node%' => $node, '%path%' => $path]), + 'package' => $this->deprecation['package'], + 'version' => $this->deprecation['version'], + 'message' => strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]), ]; } diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 0d9c91fea4667..81121b7ab9dd9 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -170,21 +170,8 @@ public function isRequired() * * @return $this */ - public function setDeprecated(/* string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */) + public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.') { - $args = \func_get_args(); - - if (\func_num_args() < 2) { - trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__); - - $message = $args[0] ?? 'The child node "%node%" at path "%path%" is deprecated.'; - $package = $version = ''; - } else { - $package = (string) $args[0]; - $version = (string) $args[1]; - $message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.'); - } - $this->deprecation = [ 'package' => $package, 'version' => $version, diff --git a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php index e235ea04956a6..da0b55ba8ca61 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php @@ -18,14 +18,8 @@ */ class FileLoaderImportCircularReferenceException extends LoaderLoadException { - public function __construct(array $resources, ?int $code = 0, \Throwable $previous = null) + public function __construct(array $resources, int $code = 0, \Throwable $previous = null) { - if (null === $code) { - trigger_deprecation('symfony/config', '5.3', 'Passing null as $code to "%s()" is deprecated, pass 0 instead.', __METHOD__); - - $code = 0; - } - $message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]); \Exception::__construct($message, $code, $previous); diff --git a/src/Symfony/Component/Config/Exception/LoaderLoadException.php b/src/Symfony/Component/Config/Exception/LoaderLoadException.php index b20e74db463f4..7c00284b07a45 100644 --- a/src/Symfony/Component/Config/Exception/LoaderLoadException.php +++ b/src/Symfony/Component/Config/Exception/LoaderLoadException.php @@ -21,18 +21,12 @@ class LoaderLoadException extends \Exception /** * @param string $resource The resource that could not be imported * @param string|null $sourceResource The original resource importing the new resource - * @param int|null $code The error code + * @param int $code The error code * @param \Throwable|null $previous A previous exception * @param string|null $type The type of resource */ - public function __construct(string $resource, string $sourceResource = null, ?int $code = 0, \Throwable $previous = null, string $type = null) + public function __construct(string $resource, string $sourceResource = null, int $code = 0, \Throwable $previous = null, string $type = null) { - if (null === $code) { - trigger_deprecation('symfony/config', '5.3', 'Passing null as $code to "%s()" is deprecated, pass 0 instead.', __METHOD__); - - $code = 0; - } - $message = ''; if ($previous) { // Include the previous exception, to help the user see what might be the underlying cause diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index c7a271c0c3128..d2e5ba816cd54 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; @@ -20,8 +19,6 @@ class ArrayNodeTest extends TestCase { - use ExpectDeprecationTrait; - public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed() { $this->expectException(InvalidTypeException::class); @@ -263,37 +260,6 @@ public function testSetDeprecated() $this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } - /** - * @group legacy - */ - public function testUnDeprecateANode() - { - $this->expectDeprecation('Since symfony/config 5.1: The signature of method "Symfony\Component\Config\Definition\BaseNode::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.'); - $this->expectDeprecation('Since symfony/config 5.1: Passing a null message to un-deprecate a node is deprecated.'); - - $node = new ArrayNode('foo'); - $node->setDeprecated('"%node%" is deprecated'); - $node->setDeprecated(null); - - $this->assertFalse($node->isDeprecated()); - } - - /** - * @group legacy - */ - public function testSetDeprecatedWithoutPackageAndVersion() - { - $this->expectDeprecation('Since symfony/config 5.1: The signature of method "Symfony\Component\Config\Definition\BaseNode::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.'); - - $node = new ArrayNode('foo'); - $node->setDeprecated('"%node%" is deprecated'); - - $deprecation = $node->getDeprecation($node->getName(), $node->getPath()); - $this->assertSame('"foo" is deprecated', $deprecation['message']); - $this->assertSame('', $deprecation['package']); - $this->assertSame('', $deprecation['version']); - } - /** * @dataProvider getDataWithIncludedExtraKeys */ diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index a1a658d93bf69..6bcaf700fa9d9 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition; use Symfony\Component\Config\Definition\Builder\NodeDefinition; @@ -24,8 +23,6 @@ class ArrayNodeDefinitionTest extends TestCase { - use ExpectDeprecationTrait; - public function testAppendingSomeNode() { $parent = new ArrayNodeDefinition('root'); @@ -349,27 +346,6 @@ public function testSetDeprecated() $this->assertSame('1.1', $deprecation['version']); } - /** - * @group legacy - */ - public function testSetDeprecatedWithoutPackageAndVersion() - { - $this->expectDeprecation('Since symfony/config 5.1: The signature of method "Symfony\Component\Config\Definition\Builder\NodeDefinition::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.'); - $node = new ArrayNodeDefinition('root'); - $node - ->children() - ->arrayNode('foo')->setDeprecated('The "%path%" node is deprecated.')->end() - ->end() - ; - $deprecatedNode = $node->getNode()->getChildren()['foo']; - - $this->assertTrue($deprecatedNode->isDeprecated()); - $deprecation = $deprecatedNode->getDeprecation($deprecatedNode->getName(), $deprecatedNode->getPath()); - $this->assertSame('The "root.foo" node is deprecated.', $deprecation['message']); - $this->assertSame('', $deprecation['package']); - $this->assertSame('', $deprecation['version']); - } - public function testCannotBeEmptyOnConcreteNode() { $this->expectException(InvalidDefinitionException::class);