8000 Merge branch '3.4' into 4.3 · symfony/symfony@43e1c8e · GitHub
[go: up one dir, main page]

Skip to content

Commit 43e1c8e

Browse files
Merge branch '3.4' into 4.3
* 3.4: [DependencyInjection] Fixed the `getServiceIds` implementation to always return aliases
2 parents 113fa0b + a5d776d commit 43e1c8e

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public function reset()
326326
*/
327327
public function getServiceIds()
328328
{
329-
return array_map('strval', array_unique(array_merge(['service_container'], array_keys($this->fileMap), array_keys($this->methodMap), array_keys($this->services))));
329+
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))));
330330
}
331331

332332
/**

src/Symfony/Component/DependencyInjection/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()

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

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

1247+
public function testAliasCanBeFoundInTheDumpedContainerWhenBothTheAliasAndTheServiceArePublic()
1248+
{
1249+
$container = new ContainerBuilder();
1250+
1251+
$container->register('foo', 'stdClass')->setPublic(true);
1252+
$container->setAlias('bar', 'foo')->setPublic(true);
1253+
1254+
$container->compile();
1255+
1256+
// Bar is found in the compiled container
1257+
$service_ids = $container->getServiceIds();
1258+
$this->assertContains('bar', $service_ids);
1259+
1260+
$dumper = new PhpDumper($container);
1261+
$dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_AliasesCanBeFoundInTheDumpedContainer']);
1262+
eval('?>'.$dump);
1263+
1264+
$container = new \Symfony_DI_PhpDumper_AliasesCanBeFoundInTheDumpedContainer();
1265+
1266+
// Bar should still be found in the compiled container
1267+
$service_ids = $container->getServiceIds();
1268+
$this->assertContains('bar', $service_ids);
1269+
}
1270+
12471271
public function testWither()
12481272
{
12491273
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)
0