diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index b34717553c..9454d1bd4b 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -182,6 +182,7 @@ class AutowirePass implements CompilerPassInterface foreach ($definition->getAutowiringTypes() as $type) { $this->definedTypes[$type] = true; $this->types[$type] = $id; + unset($this->notGuessableTypes[$type]); } if (!$reflectionClass = $this->getReflectionClass($id, $definition)) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 7bf3ad0a30..0ad135ff9e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -173,7 +173,8 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase $container = new ContainerBuilder(); $container->register('a1', __NAMESPACE__.'\Foo'); - $container->register('a2', __NAMESPACE__.'\Foo')->addAutowiringType(__NAMESPACE__.'\Foo'); + $container->register('a2', __NAMESPACE__.'\Foo'); + $container->register('a3', __NAMESPACE__.'\Foo')->addAutowiringType(__NAMESPACE__.'\Foo'); $aDefinition = $container->register('a', __NAMESPACE__.'\NotGuessableArgument'); $aDefinition->setAutowired(true); @@ -181,7 +182,7 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase $pass->process($container); $this->assertCount(1, $container->getDefinition('a')->getArguments()); - $this->assertEquals('a2', (string) $container->getDefinition('a')->getArgument(0)); + $this->assertEquals('a3', (string) $container->getDefinition('a')->getArgument(0)); } public function testWithTypeSet()