diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php new file mode 100644 index 0000000000..305b206c88 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php @@ -0,0 +1,21 @@ +bars = \iterator_to_array($bars); + } + + public function getDefaultBar(): BarInterface + { + return reset($this->bars); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/service_instanceof_factory.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/service_instanceof_factory.yml new file mode 100644 index 0000000000..4ae8303855 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/service_instanceof_factory.yml @@ -0,0 +1,14 @@ +services: + _instanceof: + Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface: + tags: + - { name: bar } + + Symfony\Component\DependencyInjection\Tests\Fixtures\Bar: + public: true + + Symfony\Component\DependencyInjection\Tests\Fixtures\BarFactory: + arguments: [!tagged 'bar'] + + Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface: + factory: ['@Symfony\Component\DependencyInjection\Tests\Fixtures\BarFactory', 'getDefaultBar'] diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 37e6054f55..b3090786cf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -770,4 +770,15 @@ class YamlFileLoaderTest extends TestCase $definition = $container->getDefinition('foo'); $this->assertSame([['interface' => 'SomeInterface']], $definition->getTag('proxy')); } + + public function testServiceWithSameNameAsInterfaceAndFactoryIsNotTagged() + { + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('service_instanceof_factory.yml'); + $container->compile(); + + $tagged = $container->findTaggedServiceIds('bar'); + $this->assertCount(1, $tagged); + } }