diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index 4d15e9aeda..1cb6ca1e32 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + * Dropped support for constructing a `TreeBuilder` without passing root node information. + * Removed the `root()` method in `TreeBuilder`, pass the root node information to the constructor instead + 4.3.0 ----- diff --git a/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php index 9a3b0351d2..6cb5585a63 100644 --- a/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php @@ -24,36 +24,10 @@ class TreeBuilder implements NodeParentInterface protected $tree; protected $root; - public function __construct(string $name = null, string $type = 'array', NodeBuilder $builder = null) + public function __construct(string $name, string $type = 'array', NodeBuilder $builder = null) { - if (null === $name) { - @trigger_error('A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.', E_USER_DEPRECATED); - } else { - $builder = $builder ?: new NodeBuilder(); - $this->root = $builder->node($name, $type)->setParent($this); - } - } - - /** - * Creates the root node. - * - * @param string $name The name of the root node - * @param string $type The type of the root node - * @param NodeBuilder $builder A custom node builder instance - * - * @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array') - * - * @throws \RuntimeException When the node type is not supported - * - * @deprecated since Symfony 4.3, pass the root name to the constructor instead - */ - public function root($name, $type = 'array', NodeBuilder $builder = null) - { - @trigger_error(sprintf('The "%s()" method called for the "%s" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.', __METHOD__, $name), E_USER_DEPRECATED); - $builder = $builder ?: new NodeBuilder(); - - return $this->root = $builder->node($name, $type)->setParent($this); + $this->root = $builder->node($name, $type)->setParent($this); } /** diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php index d0e3d2d52d..b45d74fb99 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php @@ -188,23 +188,4 @@ class TreeBuilderTest extends TestCase $this->assertInstanceOf('Symfony\Component\Config\Definition\BaseNode', $childChildren['foo']); $this->assertSame('propagation/child/foo', $childChildren['foo']->getPath()); } - - /** - * @group legacy - * @expectedDeprecation A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0. - */ - public function testInitializingTreeBuildersWithoutRootNode() - { - new TreeBuilder(); - } - - /** - * @group legacy - * @expectedDeprecation The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "foo" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead. - */ - public function testRoot() - { - $builder = new TreeBuilder('foo'); - $builder->root('foo'); - } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index 47343ec951..c7ecfd4b71 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -390,7 +390,7 @@ class EnvConfigurationWithoutRootNode implements ConfigurationInterface { public function getConfigTreeBuilder() { - return new TreeBuilder(); + return new TreeBuilder('env_extension'); } } @@ -398,8 +398,8 @@ class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInte { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('env_extension') + $treeBuilder = new TreeBuilder('env_extension'); + $treeBuilder ->children() ->arrayNode('nodes') ->isRequired()