8000 Deprecate TreeBuilder::root · symfony/symfony@8f24200 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f24200

Browse files
committed
Deprecate TreeBuilder::root
1 parent 9a7a276 commit 8f24200

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function __construct(string $name = null, string $type = 'array', NodeBui
2929
if (null === $name) {
3030
@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);
3131
} else {
32-
$this->root($name, $type, $builder);
32+
$builder = $builder ?: new NodeBuilder();
33+
$this->root = $builder->node($name, $type)->setParent($this);
3334
}
3435
}
3536

@@ -43,9 +44,13 @@ public function __construct(string $name = null, string $type = 'array', NodeBui
4344
* @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
4445
*
4546
* @throws \RuntimeException When the node type is not supported
47+
*
48+
* @deprecated since Symfony 4.3, pass the root name to the constructor instead
4649
*/
4750
public function root($name, $type = 'array', NodeBuilder $builder = null)
4851
{
52+
@trigger_error(sprintf('The "%s()" method (called for "%s") is deprecated since Symfony 4.3, pass the root name to the constructor instead.', __METHOD__, $name), E_USER_DEPRECATED);
53+
4954
$builder = $builder ?: new NodeBuilder();
5055

5156
return $this->root = $builder->node($name, $type)->setParent($this);

0 commit comments

Comments
 (0)
0