Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5981278

Browse files
committed
[DependencyInjection] Fix using autowiring types when there are more than 2 services
1 parent 33bae93 commit 5981278

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ private function populateAvailableType($id, Definition $definition)
169169
foreach ($definition->getAutowiringTypes() as $type) {
170170
$this->definedTypes[$type] = true;
171171
$this->types[$type] = $id;
172+
unset($this->notGuessableTypes[$type]);
172173
}
173174

174175
if (!$reflectionClass = $this->getReflectionClass($id, $definition)) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,16 @@ public function testTypeNotGuessableWithTypeSet()
173173
$container = new ContainerBuilder();
174174

175175
$container->register('a1', __NAMESPACE__.'\Foo');
176-
$container->register('a2', __NAMESPACE__.'\Foo')->addAutowiringType(__NAMESPACE__.'\Foo');
176+
$container->register('a2', __NAMESPACE__.'\Foo');
177+
$container->register('a3', __NAMESPACE__.'\Foo')->addAutowiringType(__NAMESPACE__.'\Foo');
177178
$aDefinition = $container->register('a', __NAMESPACE__.'\NotGuessableArgument');
178179
$aDefinition->setAutowired(true);
179180

180181
$pass = new AutowirePass();
181182
$pass->process($container);
182183

183184
$this->assertCount(1, $container->getDefinition('a')->getArguments());
184-
$this->assertEquals('a2', (string) $container->getDefinition('a')->getArgument(0));
185+
$this->assertEquals('a3', (string) $container->getDefinition('a')->getArgument(0));
185186
}
186187

187188
public function testWithTypeSet()

0 commit comments

Comments
 (0)