diff --git a/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php index 6cb5585a637dc..13a18db3ae1c5 100644 --- a/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Config\Definition\Builder; -use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException; use Symfony\Component\Config\Definition\NodeInterface; /** @@ -35,10 +34,6 @@ public function __construct(string $name, string $type = 'array', NodeBuilder $b */ public function getRootNode(): NodeDefinition { - if (null === $this->root) { - throw new \RuntimeException(sprintf('Calling %s() before creating the root node is not supported, migrate to the new constructor signature instead.', __METHOD__)); - } - return $this->root; } @@ -51,7 +46,6 @@ public function getRootNode(): NodeDefinition */ public function buildTree() { - $this->assertTreeHasRootNode(); if (null !== $this->tree) { return $this->tree; } @@ -61,21 +55,9 @@ public function buildTree() public function setPathSeparator(string $separator) { - $this->assertTreeHasRootNode(); - // unset last built as changing path separator changes all nodes $this->tree = null; $this->root->setPathSeparator($separator); } - - /** - * @throws \RuntimeException if root node is not defined - */ - private function assertTreeHasRootNode() - { - if (null === $this->root) { - throw new TreeWithoutRootNodeException('The configuration tree has no root node.'); - } - } } diff --git a/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php b/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php deleted file mode 100644 index 67b0c4bb2e084..0000000000000 --- a/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Config\Definition\Exception; - -/** - * @author Roland Franssen - */ -class TreeWithoutRootNodeException extends \RuntimeException -{ -} diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php index 8fd84fac00eeb..be0f1edd201fe 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php @@ -12,7 +12,6 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\Config\Definition\BaseNode; -use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface; @@ -80,10 +79,7 @@ public function process(ContainerBuilder $container) continue; } - try { - $this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config); - } catch (TreeWithoutRootNodeException $e) { - } + $this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config); } } finally { BaseNode::resetPlaceholders(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index b370c177c87df..84d6d8db82835 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -14,7 +14,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException; use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass; use Symfony\Component\DependencyInjection\Compiler\RegisterEnvVarProcessorsPass; use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass; @@ -274,20 +273,6 @@ public function testEnvWithVariableNode(): void $this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig())); } - /** - * @group legacy - */ - public function testConfigurationWithoutRootNode(): void - { - $container = new ContainerBuilder(); - $container->registerExtension(new EnvExtension(new EnvConfigurationWithoutRootNode())); - $container->loadFromExtension('env_extension'); - - $this->doProcess($container); - - $this->addToAssertionCount(1); - } - public function testEmptyConfigFromMoreThanOneSource() { $container = new ContainerBuilder(); @@ -386,14 +371,6 @@ public function getConfigTreeBuilder() } } -class EnvConfigurationWithoutRootNode implements ConfigurationInterface -{ - public function getConfigTreeBuilder() - { - return new TreeBuilder('env_extension'); - } -} - class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface { public function getConfigTreeBuilder() @@ -438,11 +415,7 @@ public function load(array $configs, ContainerBuilder $container) return; } - try { - $this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); - } catch (TreeWithoutRootNodeException $e) { - $this->config = null; - } + $this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); } public function getConfig()