8000 [DI] configure inlined services before injecting when dumping the con… · symfony/symfony@3e3d2ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e3d2ea

Browse files
[DI] configure inlined services before injecting when dumping the container
1 parent 432487f commit 3e3d2ea

8 files changed

+141
-272
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 133 additions & 241 deletions
Large diffs are not rendered by default.

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ protected function getConfiguredServiceService()
172172

173173
$a = new \ConfClass();
174174
$a->setFoo(($this->services['baz'] ?? $this->getBazService()));
175-
176175
$a->configureStdClass($instance);
177176

178177
return $instance;
@@ -301,10 +300,8 @@ protected function getFooWithInlineService()
301300
$this->services['foo_with_inline'] = $instance = new \Foo();
302301

303302
$a = new \Bar();
304-
305303
$a->pub = 'pub';
306304
$a->setBaz(($this->services['baz'] ?? $this->getBazService()));
307-
308305
$instance->setBar($a);
309306

310307
return $instance;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ protected function getBar3Service()
105105
$this->services['bar3'] = $instance = new \BarCircular();
106106

107107
$a = new \FoobarCircular();
108-
109108
$instance->addFoobar($a, $a);
110109

111110
return $instance;
@@ -119,7 +118,6 @@ protected function getBar3Service()
119118
protected function getConnectionService()
120119
{
121120
$a = new \stdClass();
122-
123121
$b = new \stdClass();
124122

125123
$this->services['connection'] = $instance = new \stdClass($a, $b);
@@ -138,18 +136,15 @@ protected function getConnectionService()
138136
protected function getConnection2Service()
139137
{
140138
$a = new \stdClass();
139+
$c = new \stdClass();
141140

142-
$b = new \stdClass();
143-
144-
$this->services['connection2'] = $instance = new \stdClass($a, $b);
145-
146-
$c = ($this->services['manager2'] ?? $this->getManager2Service());
141+
$this->services['connection2'] = $instance = new \stdClass($a, $c);
147142

143+
$b = ($this->services['manager2'] ?? $this->getManager2Service());
144+
$a->subscriber2 = new \stdClass($b);
148145
$d = new \stdClass($instance);
149-
150-
$a->subscriber2 = new \stdClass($c);
151-
$d->handler2 = new \stdClass($c);
152-
$b->logger2 = $d;
146+
$d->handler2 = new \stdClass($b);
147+
$c->logger2 = $d;
153148

154149
return $instance;
155150
}
@@ -196,9 +191,7 @@ protected function getFoo5Service()
196191
$this->services['foo5'] = $instance = new \stdClass();
197192

198193
$a = new \stdClass($instance);
199-
200194
$a->foo = $instance;
201-
202195
$instance->bar = $a;
203196

204197
return $instance;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ protected function getBar3Service()
105105
$this->services['bar3'] = $instance = new \BarCircular();
106106

107107
$a = ($this->services['foobar3'] ?? $this->services['foobar3'] = new \FoobarCircular());
108-
109108
$instance->addFoobar($a, $a);
110109

111110
return $instance;
@@ -143,7 +142,6 @@ protected function getConnectionService()
143142
if (isset($this->services['connection'])) {
144143
return $this->services['connection'];
145144
}
146-
147145
$b = new \stdClass();
148146

149147
$this->services['connection'] = $instance = new \stdClass($a, $b);
@@ -165,13 +163,11 @@ protected function getConnection2Service()
165163
if (isset($this->services['connection2'])) {
166164
return $this->services['connection2'];
167165
}
168-
169166
$b = new \stdClass();
170167

171168
$this->services['connection2'] = $instance = new \stdClass($a, $b);
172169

173170
$c = new \stdClass($instance);
174-
175171
$c->handler2 = new \stdClass(($this->services['manager2'] ?? $this->getManager2Service()));
176172
$b->logger2 = $c;
177173

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,11 @@ protected function getFooService()
8585
if (isset($this->services['foo'])) {
8686
return $this->services['foo'];
8787
}
88-
8988
$b = new \c2();
90-
91-
$this->services['foo'] = $instance = new \c1($a, $b);
92-
9389
$c = new \c3();
94-
9590
$c->p3 = new \c4();
9691
$b->p2 = $c;
9792

98-
return $instance;
93+
return $this->services['foo'] = new \c1($a, $b);
9994
}
10095
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ protected function getConfiguredServiceService()
172172

173173
$a = new \ConfClass();
174174
$a->setFoo(($this->services['baz'] ?? $this->getBazService()));
175-
176175
$a->configureStdClass($instance);
177176

178177
return $instance;
@@ -301,10 +300,8 @@ protected function getFooWithInlineService()
301300
$this->services['foo_with_inline'] = $instance = new \Foo();
302301

303302
$a = new \Bar();
304-
305303
$a->pub = 'pub';
306304
$a->setBaz(($this->services['baz'] ?? $this->getBazService()));
307-
308305
$instance->setBar($a);
309306

310307
return $instance;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ protected function getC1Service()
101101
*/
102102
protected function getC2Service()
103103
{
104-
include_once $this->targetDirs[1].'/includes/HotPath/C3.php';
105104
include_once $this->targetDirs[1].'/includes/HotPath/C2.php';
105+
include_once $this->targetDirs[1].'/includes/HotPath/C3.php';
106106

107107
return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3());
108108
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ protected function getTranslator3Service()
165165
})));
166166

167167
$a = ($this->services['translator.loader_3'] ?? $this->services['translator.loader_3'] = new \stdClass());
168-
169168
$instance->addResource('db', $a, 'nl');
170169
$instance->addResource('db', $a, 'en');
171170

0 commit comments

Comments
 (0)
0