Skip to content

Commit f6b9d89

Browse files
Merge branch '3.4' into 4.1
* 3.4: [php_cs] disable fopen_flags [DI] fix error in dumped container [CS] Remove unused variables passed to closures [DI] fix dumping setters before their inlined instances [CS] Remove empty comment [CS] Enforces null type hint on last position in phpDocs [CS] Use combined assignment operators when possible Fix a typo in error messages Don't return early as this bypasses the auto exit feature [Console] Add missing null to input values allowed types [PHPUnitBridge] Fix microtime() format bumped Symfony version to 3.4.17 updated VERSION for 3.4.16 updated CHANGELOG for 3.4.16 bumped Symfony version to 2.8.47 update CONTRIBUTORS for 2.8.46 updated VERSION for 2.8.46 updated CHANGELOG for 2.8.46
2 parents 985ebee + aea20fe commit f6b9d89

13 files changed

+291
-7
lines changed

ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ public function register($id, $class = null)
917917
* an autowired definition.
918918
*
919919
* @param string $id The service identifier
920-
* @param null|string $class The service class
920+
* @param string|null $class The service class
921921
*
922922
* @return Definition The created definition
923923
*/

Definition.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public function getFactory()
125125
/**
126126
* Sets the service that this service is decorating.
127127
*
128-
* @param null|string $id The decorated service id, use null to remove decoration
129-
* @param null|string $renamedId The new decorated service id
128+
* @param string|null $id The decorated service id, use null to remove decoration
129+
* @param string|null $renamedId The new decorated service id
130130
* @param int $priority The priority of decoration
131131
*
132132
* @return $this
@@ -153,7 +153,7 @@ public function setDecoratedService($id, $renamedId = null, $priority = 0)
153153
/**
154154
* Gets the service that this service is decorating.
155155
*
156-
* @return null|array An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated
156+
* @return array|null An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated
157157
*/
158158
public function getDecoratedService()
159159
{

Dumper/PhpDumper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,9 @@ private function addInlineService(string &$head, string &$tail, string $id, Defi
747747

748748
$code = '';
749749
$arguments = array($definition->getProperties(), $definition->getMethodCalls(), $definition->getConfigurator());
750-
$hasSelfRef = $this->addInlineVariables($code, $tail, $id, $arguments, false) || $hasSelfRef;
750+
$hasSelfRef = $this->addInlineVariables($code, $code, $id, $arguments, false) || $hasSelfRef;
751751

752+
$code .= '' !== $code ? "\n" : '';
752753
$code .= $this->addServiceProperties($definition, $name);
753754
$code .= $this->addServiceMethodCalls($definition, $name);
754755
$code .= $this->addServiceConfigurator($definition, $name);

Loader/Configurator/Traits/DecorateTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ trait DecorateTrait
1818
/**
1919
* Sets the service that this service is decorating.
2020
*
21-
* @param null|string $id The decorated service id, use null to remove decoration
22-
* @param null|string $renamedId The new decorated service id
21+
* @param string|null $id The decorated service id, use null to remove decoration
22+
* @param string|null $renamedId The new decorated service id
2323
* @param int $priority The priority of decoration
2424
*
2525
* @return $this

Tests/ContainerBuilderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,9 @@ public function testAlmostCircular($visibility)
13591359

13601360
$manager = $container->get('manager2');
13611361
$this->assertEquals(new \stdClass(), $manager);
1362+
1363+
$foo6 = $container->get('foo6');
1364+
$this->assertEquals((object) array('bar6' => (object) array()), $foo6);
13621365
}
13631366

13641367
public function provideAlmostCircular()

Tests/Dumper/PhpDumperTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,9 @@ public function testAlmostCircular($visibility)
870870

871871
$manager = $container->get('manager2');
872872
$this->assertEquals(new \stdClass(), $manager);
873+
874+
$foo6 = $container->get('foo6');
875+
$this->assertEquals((object) array('bar6' => (object) array()), $foo6);
873876
}
874877

875878
public function provideAlmostCircular()

Tests/Fixtures/containers/container_almost_circular.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,18 @@
101101
$container->register('subscriber2', 'stdClass')->setPublic(false)
102102
->addArgument(new Reference('manager2'));
103103

104+
// private service involved in a loop
105+
106+
$container->register('foo6', 'stdClass')
107+
->setPublic(true)
108+
->setProperty('bar6', new Reference('bar6'));
109+
110+
$container->register('bar6', 'stdClass')
111+
->setPublic(false)
112+
->addArgument(new Reference('foo6'));
113+
114+
$container->register('baz6', 'stdClass')
115+
->setPublic(true)
116+
->setProperty('bar6', new Reference('bar6'));
117+
104118
return $container;

Tests/Fixtures/php/services_almost_circular_private.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ public function __construct()
3030
$this->methodMap = array(
3131
'bar2' => 'getBar2Service',
3232
'bar3' => 'getBar3Service',
33+
'baz6' => 'getBaz6Service',
3334
'connection' => 'getConnectionService',
3435
'connection2' => 'getConnection2Service',
3536
'foo' => 'getFooService',
3637
'foo2' => 'getFoo2Service',
3738
'foo5' => 'getFoo5Service',
39+
'foo6' => 'getFoo6Service',
3840
'foobar4' => 'getFoobar4Service',
3941
'logger' => 'getLoggerService',
4042
'manager' => 'getManagerService',
@@ -68,6 +70,7 @@ public function getRemovedIds()
6870
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
6971
'bar' => true,
7072
'bar5' => true,
73+
'bar6' => true,
7174
'config' => true,
7275
'config2' => true,
7376
'dispatcher' => true,
@@ -111,6 +114,20 @@ protected function getBar3Service()
111114
return $instance;
112115
}
113116

117+
/**
118+
* Gets the public 'baz6' shared service.
119+
*
120+
* @return \stdClass
121+
*/
122+
protected function getBaz6Service()
123+
{
124+
$this->services['baz6'] = $instance = new \stdClass();
125+
126+
$instance->bar6 = ($this->privates['bar6'] ?? $this->getBar6Service());
127+
128+
return $instance;
129+
}
130+
114131
/**
115132
* Gets the public 'connection' shared service.
116133
*
@@ -207,6 +224,20 @@ protected function getFoo5Service()
207224
return $instance;
208225
}
209226

227+
/**
228+
* Gets the public 'foo6' shared service.
229+
*
230+
* @return \stdClass
231+
*/
232+
protected function getFoo6Service()
233+
{
234+
$this->services['foo6'] = $instance = new \stdClass();
235+
236+
$instance->bar6 = ($this->privates['bar6'] ?? $this->getBar6Service());
237+
238+
return $instance;
239+
}
240+
210241
/**
211242
* Gets the public 'foobar4' shared service.
212243
*
@@ -290,4 +321,20 @@ protected function getSubscriberService()
290321

291322
return $this->services['subscriber'] = new \stdClass($a);
292323
}
324+
325+
/**
326+
* Gets the private 'bar6' shared service.
327+
*
328+
* @return \stdClass
329+
*/
330+
protected function getBar6Service()
331+
{
332+
$a = ($this->services['foo6'] ?? $this->getFoo6Service());
333+
334+
if (isset($this->privates['bar6'])) {
335+
return $this->privates['bar6'];
336+
}
337+
338+
return $this->privates['bar6'] = new \stdClass($a);
339+
}
293340
}

Tests/Fixtures/php/services_almost_circular_public.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __construct()
3131
'bar' => 'getBarService',
3232
'bar3' => 'getBar3Service',
3333
'bar5' => 'getBar5Service',
34+
'baz6' => 'getBaz6Service',
3435
'connection' => 'getConnectionService',
3536
'connection2' => 'getConnection2Service',
3637
'dispatcher' => 'getDispatcherService',
@@ -39,6 +40,7 @@ public function __construct()
3940
'foo2' => 'getFoo2Service',
4041
'foo4' => 'getFoo4Service',
4142
'foo5' => 'getFoo5Service',
43+
'foo6' => 'getFoo6Service',
4244
'foobar' => 'getFoobarService',
4345
'foobar2' => 'getFoobar2Service',
4446
'foobar3' => 'getFoobar3Service',
@@ -74,6 +76,7 @@ public function getRemovedIds()
7476
'Psr\\Container\\ContainerInterface' => true,
7577
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
7678
'bar2' => true,
79+
'bar6' => true,
7780
'config' => true,
7881
'config2' => true,
7982
'logger2' => true,
@@ -131,6 +134,20 @@ protected function getBar5Service()
131134
return $instance;
132135
}
133136

137+
/**
138+
* Gets the public 'baz6' shared service.
139+
*
140+
* @return \stdClass
141+
*/
142+
protected function getBaz6Service()
143+
{
144+
$this->services['baz6'] = $instance = new \stdClass();
145+
146+
$instance->bar6 = ($this->privates['bar6'] ?? $this->getBar6Service());
147+
148+
return $instance;
149+
}
150+
134151
/**
135152
* Gets the public 'connection' shared service.
136153
*
@@ -255,6 +272,20 @@ protected function getFoo5Service()
255272
return $instance;
256273
}
257274

275+
/**
276+
* Gets the public 'foo6' shared service.
277+
*
278+
* @return \stdClass
279+
*/
280+
protected function getFoo6Service()
281+
{
282+
$this->services['foo6'] = $instance = new \stdClass();
283+
284+
$instance->bar6 = ($this->privates['bar6'] ?? $this->getBar6Service());
285+
286+
return $instance;
287+
}
288+
258289
/**
259290
* Gets the public 'foobar' shared service.
260291
*
@@ -374,4 +405,20 @@ protected function getSubscriberService()
374405
{
375406
return $this->services['subscriber'] = new \stdClass(($this->services['manager'] ?? $this->getManagerService()));
376407
}
408+
409+
/**
410+
* Gets the private 'bar6' shared service.
411+
*
412+
* @return \stdClass
413+
*/
414+
protected function getBar6Service()
415+
{
416+
$a = ($this->services['foo6'] ?? $this->getFoo6Service());
417+
418+
if (isset($this->privates['bar6'])) {
419+
return $this->privates['bar6'];
420+
}
421+
422+
return $this->privates['bar6'] = new \stdClass($a);
423+
}
377424
}

Tests/Fixtures/php/services_deep_graph.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected function getFooService()
8989
$b = new \stdClass();
9090
$c = new \stdClass();
9191
$c->p3 = new \stdClass();
92+
9293
$b->p2 = $c;
9394

9495
return $this->services['foo'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\FooForDeepGraph($a, $b);

0 commit comments

Comments
 (0)