Skip to content

Commit 85113f1

Browse files
Merge branch '4.3' into 4.4
* 4.3: [DependencyInjection] Fixed the `getServiceIds` implementation to always return aliases [Messenger] Stop worker when it should stop
2 parents 2d6eff3 + d3ad14b commit 85113f1

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function reset()
332332
*/
333333
public function getServiceIds()
334334
{
335-
return array_map('strval', array_unique(array_merge(['service_container'], array_keys($this->fileMap), array_keys($this->methodMap), array_keys($this->services))));
335+
return array_map('strval', array_unique(array_merge(['service_container'], array_keys($this->fileMap), array_keys($this->methodMap), array_keys($this->aliases), array_keys($this->services))));
336336
}
337337

338338
/**

Tests/ContainerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testGetServiceIds()
139139

140140
$sc = new ProjectServiceContainer();
141141
$sc->set('foo', $obj = new \stdClass());
142-
$this->assertEquals(['service_container', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'internal_dependency', 'foo'], $sc->getServiceIds(), '->getServiceIds() returns defined service ids by factory methods in the method map, followed by service ids defined by set()');
142+
$this->assertEquals(['service_container', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'internal_dependency', 'alias', 'foo'], $sc->getServiceIds(), '->getServiceIds() returns defined service ids by factory methods in the method map, followed by service ids defined by set()');
143143
}
144144

145145
public function testSet()

Tests/Dumper/PhpDumperTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,30 @@ public function testScalarService()
13001300
$this->assertSame('some value', $container->get('bar')->foo);
13011301
}
13021302

1303+
public function testAliasCanBeFoundInTheDumpedContainerWhenBothTheAliasAndTheServiceArePublic()
1304+
{
1305+
$container = new ContainerBuilder();
1306+
1307+
$container->register('foo', 'stdClass')->setPublic(true);
1308+
$container->setAlias('bar', 'foo')->setPublic(true);
1309+
1310+
$container->compile();
1311+
1312+
// Bar is found in the compiled container
1313+
$service_ids = $container->getServiceIds();
1314+
$this->assertContains('bar', $service_ids);
1315+
1316+
$dumper = new PhpDumper($container);
1317+
$dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_AliasesCanBeFoundInTheDumpedContainer']);
1318+
eval('?>'.$dump);
1319+
1320+
$container = new \Symfony_DI_PhpDumper_AliasesCanBeFoundInTheDumpedContainer();
1321+
1322+
// Bar should still be found in the compiled container
1323+
$service_ids = $container->getServiceIds();
1324+
$this->assertContains('bar', $service_ids);
1325+
}
1326+
13031327
public function testWither()
13041328
{
13051329
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)