8000 minor #31932 [Config] remove the root method and the nullable name (S… · symfony/symfony@0fb9b1b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fb9b1b

Browse files
minor #31932 [Config] remove the root method and the nullable name (Simperfit)
This PR was merged into the 5.0-dev branch. Discussion ---------- [Config] remove the root method and the nullable name | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | none <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | none <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> This PR allows to remove the both deprecated path of the `TreeBuilder` and update tests accordingly. Commits ------- 7c66e6f [Config] remove the root method and the nullable name
2 parents 1af3952 + 7c66e6f commit 0fb9b1b

File tree

4 files changed

+10
-50
lines changed

4 files changed

+10
-50
lines changed

src/Symfony/Component/Config/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.0.0
5+
-----
6+
* Dropped support for constructing a `TreeBuilder` without passing root node information.
7+
* Removed the `root()` method in `TreeBuilder`, pass the root node information to the constructor instead
8+
49
4.3.0
510
-----
611

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

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,10 @@ class TreeBuilder implements NodeParentInterface
2424
protected $tree;
2525
protected $root;
2626

27-
public function __construct(string $name = null, string $type = 'array', NodeBuilder $builder = null)
27+
public function __construct(string $name, string $type = 'array', NodeBuilder $builder = null)
2828
{
29-
if (null === $name) {
30-
@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);
31-
} else {
32-
$builder = $builder ?: new NodeBuilder();
33-
$this->root = $builder->node($name, $type)->setParent($this);
34-
}
35-
}
36-
37-
/**
38-
* Creates the root node.
39-
*
40-
* @param string $name The name of the root node
41-
* @param string $type The type of the root node
42-
* @param NodeBuilder $builder A custom node builder instance
43-
*
44-
* @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
45-
*
46-
* @throws \RuntimeException When the node type is not supported
47-
*
48-
* @deprecated since Symfony 4.3, pass the root name to the constructor instead
49-
*/
50-
public function root($name, $type = 'array', NodeBuilder $builder = null)
51-
{
52-
@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);
53-
5429
$builder = $builder ?: new NodeBuilder();
55-
56-
return $this->root = $builder->node($name, $type)->setParent($this);
30+
$this->root = $builder->node($name, $type)->setParent($this);
5731
}
5832

5933
/**

src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,4 @@ public function testPathSeparatorIsPropagatedToChildren()
188188
$this->assertInstanceOf('Symfony\Component\Config\Definition\BaseNode', $childChildren['foo']);
189189
$this->assertSame('propagation/child/foo', $childChildren['foo']->getPath());
190190
}
191-
192-
/**
193-
* @group legacy
194-
* @expectedDeprecation A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
195-
*/
196-
public function testInitializingTreeBuildersWithoutRootNode()
197-
{
198-
new TreeBuilder();
199-
}
200-
201-
/**
202-
* @group legacy
203-
* @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.
204-
*/
205-
public function testRoot()
206-
{
207-
$builder = new TreeBuilder('foo');
208-
$builder->root('foo');
209-
}
210191
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,16 @@ class EnvConfigurationWithoutRootNode implements ConfigurationInterface
390390
{
391391
public function getConfigTreeBuilder()
392392
{
393-
return new TreeBuilder();
393+
return new TreeBuilder('env_extension');
394394
}
395395
}
396396

397397
class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface
398398
{
399399
public function getConfigTreeBuilder()
400400
{
401-
$treeBuilder = new TreeBuilder();
402-
$treeBuilder->root('env_extension')
401+
$treeBuilder = new TreeBuilder('env_extension');
402+
$treeBuilder
403403
->children()
404404
->arrayNode('nodes')
405405
->isRequired()

0 commit comments

Comments
 (0)
0