Skip to content

Commit 6c982e1

Browse files
committed
Fix TreeBuilder in Symfony 4.2
A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
1 parent c7000fa commit 6c982e1

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

pkg/async-event-dispatcher/DependencyInjection/Configuration.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Configuration implements ConfigurationInterface
1212
*/
1313
public function getConfigTreeBuilder()
1414
{
15-
$tb = new TreeBuilder();
16-
$rootNode = $tb->root('enqueue_async_event_dispatcher');
15+
$tb = new TreeBuilder('enqueue_async_event_dispatcher');
16+
$rootNode = $tb->getRootNode();
1717

1818
$rootNode->children()
1919
->scalarNode('context_service')->isRequired()->cannotBeEmpty()->end()

pkg/enqueue-bundle/DependencyInjection/Configuration.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function __construct(bool $debug)
2424

2525
public function getConfigTreeBuilder(): TreeBuilder
2626
{
27-
$tb = new TreeBuilder();
28-
$rootNode = $tb->root('enqueue');
27+
$tb = new TreeBuilder('enqueue');
28+
$rootNode = $tb->getRootNode();
2929

3030
$rootNode
3131
->requiresAtLeastOneElement()

pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php

+26-26
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function testThrowIfEmptyNameGivenOnConstruction()
3737

3838
public function testShouldAllowAddConfigurationAsStringDsn()
3939
{
40-
$tb = new TreeBuilder();
41-
$rootNode = $tb->root('foo');
40+
$tb = new TreeBuilder('foo');
41+
$rootNode = $tb->getRootNode();
4242

4343
$rootNode->append(TransportFactory::getConfiguration());
4444

@@ -59,8 +59,8 @@ public function testShouldAllowAddConfigurationAsStringDsn()
5959
*/
6060
public function testShouldAllowAddConfigurationAsDsnWithoutSlashes()
6161
{
62-
$tb = new TreeBuilder();
63-
$rootNode = $tb->root('foo');
62+
$tb = new TreeBuilder('foo');
63+
$rootNode = $tb->getRootNode();
6464

6565
$rootNode->append(TransportFactory::getConfiguration());
6666

@@ -76,8 +76,8 @@ public function testShouldAllowAddConfigurationAsDsnWithoutSlashes()
7676

7777
public function testShouldSetNullTransportIfNullGiven()
7878
{
79-
$tb = new TreeBuilder();
80-
$rootNode = $tb->root('foo');
79+
$tb = new TreeBuilder('foo');
80+
$rootNode = $tb->getRootNode();
8181

8282
$rootNode->append(TransportFactory::getConfiguration());
8383

@@ -93,8 +93,8 @@ public function testShouldSetNullTransportIfNullGiven()
9393

9494
public function testShouldSetNullTransportIfEmptyStringGiven()
9595
{
96-
$tb = new TreeBuilder();
97-
$rootNode = $tb->root('foo');
96+
$tb = new TreeBuilder('foo');
97+
$rootNode = $tb->getRootNode();
9898

9999
$rootNode->append(TransportFactory::getConfiguration());
100100

@@ -110,8 +110,8 @@ public function testShouldSetNullTransportIfEmptyStringGiven()
110110

111111
public function testShouldSetNullTransportIfEmptyArrayGiven()
112112
{
113-
$tb = new TreeBuilder();
114-
$rootNode = $tb->root('foo');
113+
$tb = new TreeBuilder('foo');
114+
$rootNode = $tb->getRootNode();
115115

116116
$rootNode->append(TransportFactory::getConfiguration());
117117

@@ -127,8 +127,8 @@ public function testShouldSetNullTransportIfEmptyArrayGiven()
127127

128128
public function testThrowIfEmptyDsnGiven()
129129
{
130-
$tb = new TreeBuilder();
131-
$rootNode = $tb->root('foo');
130+
$tb = new TreeBuilder('foo');
131+
$rootNode = $tb->getRootNode();
132132

133133
$rootNode->append(TransportFactory::getConfiguration());
134134

@@ -140,8 +140,8 @@ public function testThrowIfEmptyDsnGiven()
140140

141141
public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime()
142142
{
143-
$tb = new TreeBuilder();
144-
$rootNode = $tb->root('foo');
143+
$tb = new TreeBuilder('foo');
144+
$rootNode = $tb->getRootNode();
145145

146146
$rootNode->append(TransportFactory::getConfiguration());
147147

@@ -159,8 +159,8 @@ public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime()
159159

160160
public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTime()
161161
{
162-
$tb = new TreeBuilder();
163-
$rootNode = $tb->root('foo');
162+
$tb = new TreeBuilder('foo');
163+
$rootNode = $tb->getRootNode();
164164

165165
$rootNode->append(TransportFactory::getConfiguration());
166166

@@ -178,8 +178,8 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTi
178178

179179
public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSameTime()
180180
{
181-
$tb = new TreeBuilder();
182-
$rootNode = $tb->root('foo');
181+
$tb = new TreeBuilder('foo');
182+
$rootNode = $tb->getRootNode();
183183

184184
$rootNode->append(TransportFactory::getConfiguration());
185185
$processor = new Processor();
@@ -196,8 +196,8 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSame
196196

197197
public function testShouldAllowSetFactoryClass()
198198
{
199-
$tb = new TreeBuilder();
200-
$rootNode = $tb->root('foo');
199+
$tb = new TreeBuilder('foo');
200+
$rootNode = $tb->getRootNode();
201201

202202
$rootNode->append(TransportFactory::getConfiguration());
203203
$processor = new Processor();
@@ -214,8 +214,8 @@ public function testShouldAllowSetFactoryClass()
214214

215215
public function testShouldAllowSetFactoryService()
216216
{
217-
$tb = new TreeBuilder();
218-
$rootNode = $tb->root('foo');
217+
$tb = new TreeBuilder('foo');
218+
$rootNode = $tb->getRootNode();
219219

220220
$rootNode->append(TransportFactory::getConfiguration());
221221
$processor = new Processor();
@@ -232,8 +232,8 @@ public function testShouldAllowSetFactoryService()
232232

233233
public function testShouldAllowSetConnectionFactoryClass()
234234
{
235-
$tb = new TreeBuilder();
236-
$rootNode = $tb->root('foo');
235+
$tb = new TreeBuilder('foo');
236+
$rootNode = $tb->getRootNode();
237237

238238
$rootNode->append(TransportFactory::getConfiguration());
239239
$processor = new Processor();
@@ -250,8 +250,8 @@ public function testShouldAllowSetConnectionFactoryClass()
250250

251251
public function testThrowIfExtraOptionGiven()
252252
{
253-
$tb = new TreeBuilder();
254-
$rootNode = $tb->root('foo');
253+
$tb = new TreeBuilder('foo');
254+
$rootNode = $tb->getRootNode();
255255

256256
$rootNode->append(TransportFactory::getConfiguration());
257257
$processor = new Processor();

pkg/simple-client/SimpleClient.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ public function build(array $configs): void
306306

307307
private function createConfiguration(): NodeInterface
308308
{
309-
$tb = new TreeBuilder();
310-
$rootNode = $tb->root('enqueue');
309+
$tb = new TreeBuilder('enqueue');
310+
$rootNode = $tb->getRootNode();
311311

312312
$rootNode
313313
->beforeNormalization()

0 commit comments

Comments
 (0)