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

Skip to content

Commit 16edc03

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

9 files changed

+159
-272
lines changed

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

Lines changed: 140 additions & 262 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function getRemovedIds()
6767
protected function getBarService()
6868
{
6969
$a = new \stdClass();
70+
7071
$a->add($this);
7172

7273
return $this->services['bar'] = new \stdClass($a);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
7575
$this->services['configured_service'] = $instance = new \stdClass();
7676

7777
$a = new \ConfClass();
78+
7879
$a->setFoo(($this->services['baz'] ?? $this->load('getBazService.php')));
7980

8081
$a->configureStdClass($instance);
@@ -294,6 +295,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
294295
// Returns the public 'new_factory_service' shared service.
295296

296297
$a = new \FactoryClass();
298+
297299
$a->foo = 'bar';
298300

299301
$this->services['new_factory_service'] = $instance = $a->getInstance();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ protected function getConfiguredServiceService()
171171
$this->services['configured_service'] = $instance = new \stdClass();
172172

173173
$a = new \ConfClass();
174+
174175
$a->setFoo(($this->services['baz'] ?? $this->getBazService()));
175176

176177
$a->configureStdClass($instance);
@@ -365,6 +366,7 @@ protected function getMethodCall1Service()
365366
protected function getNewFactoryServiceService()
366367
{
367368
$a = new \FactoryClass();
369+
368370
$a->foo = 'bar';
369371

370372
$this->services['new_factory_service'] = $instance = $a->getInstance();

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ protected function getConnectionService()
125125
$this->services['connection'] = $instance = new \stdClass($a, $b);
126126

127127
$a->subscriber = ($this->services['subscriber'] ?? $this->getSubscriberService());
128+
128129
$b->logger = ($this->services['logger'] ?? $this->getLoggerService());
129130

130131
return $instance;
@@ -139,17 +140,19 @@ protected function getConnection2Service()
139140
{
140141
$a = new \stdClass();
141142

142-
$b = new \stdClass();
143+
$c = new \stdClass();
143144

144-
$this->services['connection2'] = $instance = new \stdClass($a, $b);
145+
$this->services['connection2'] = $instance = new \stdClass($a, $c);
145146

146-
$c = ($this->services['manager2'] ?? $this->getManager2Service());
147+
$b = ($this->services['manager2'] ?? $this->getManager2Service());
148+
149+
$a->subscriber2 = new \stdClass($b);
147150

148151
$d = new \stdClass($instance);
149152

150-
$a->subscriber2 = new \stdClass($c);
151-
$d->handler2 = new \stdClass($c);
152-
$b->logger2 = $d;
153+
$d->handler2 = new \stdClass($b);
154+
155+
$c->logger2 = $d;
153156

154157
return $instance;
155158
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ protected function getConnection2Service()
173173
$c = new \stdClass($instance);
174174

175175
$c->handler2 = new \stdClass(($this->services['manager2'] ?? $this->getManager2Service()));
176+
176177
$b->logger2 = $c;
177178

178179
return $instance;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@ protected function getFooService()
8888

8989
$b = new \c2();
9090

91-
$this->services['foo'] = $instance = new \c1($a, $b);
92-
9391
$c = new \c3();
9492

9593
$c->p3 = new \c4();
9694
$b->p2 = $c;
9795

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ protected function getConfiguredServiceService()
171171
$this->services['configured_service'] = $instance = new \stdClass();
172172

173173
$a = new \ConfClass();
174+
174175
$a->setFoo(($this->services['baz'] ?? $this->getBazService()));
175176

176177
$a->configureStdClass($instance);
@@ -365,6 +366,7 @@ protected function getMethodCall1Service()
365366
protected function getNewFactoryServiceService()
366367
{
367368
$a = new \FactoryClass();
369+
368370
$a->foo = 'bar';
369371

370372
$this->services['new_factory_service'] = $instance = $a->getInstance();

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
}

0 commit comments

Comments
 (0)
0