diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php index 87beeaa392..3d39c3f864 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php @@ -73,6 +73,8 @@ class ContainerConfigurator extends AbstractConfigurator final public function services(): ServicesConfigurator { + $this->loader->resetBeforeConfiguringServices(); + return new ServicesConfigurator($this->container, $this->loader, $this->instanceof, $this->path, $this->anonymousCount); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php index b693fc2d66..0688ef92b4 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php @@ -105,6 +105,7 @@ class ServicesConfigurator extends AbstractConfigurator $ref = static::processValue($referencedId, true); $alias = new Alias((string) $ref, $this->defaults->isPublic()); $this->container->setAlias($id, $alias); + $this->loader->removeSinglyImplementedAlias((string) $ref); return new AliasConfigurator($this, $alias); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index cb20416485..371d9862aa 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -29,6 +29,9 @@ abstract class FileLoader extends BaseFileLoader protected $container; protected $isLoadingInstanceof = false; protected $instanceof = []; + protected $interfaces = []; + protected $singlyImplemented = []; + protected $singlyImplementedAliases = []; public function __construct(ContainerBuilder $container, FileLocatorInterface $locator) { @@ -57,12 +60,10 @@ abstract class FileLoader extends BaseFileLoader $classes = $this->findClasses($namespace, $resource, (array) $exclude); // prepare for deep cloning $serializedPrototype = serialize($prototype); - $interfaces = []; - $singlyImplemented = []; foreach ($classes as $class => $errorMessage) { if (interface_exists($class, false)) { - $interfaces[] = $class; + $this->interfaces[] = $class; } else { $this->setDefinition($class, $definition = unserialize($serializedPrototype)); if (null !== $errorMessage) { @@ -71,14 +72,17 @@ abstract class FileLoader extends BaseFileLoader continue; } foreach (class_implements($class, false) as $interface) { - $singlyImplemented[$interface] = isset($singlyImplemented[$interface]) ? false : $class; + $this->singlyImplemented[$interface] = isset($this->singlyImplemented[$interface]) ? false : $class; } } } - foreach ($interfaces as $interface) { - if (!empty($singlyImplemented[$interface])) { - $this->container->setAlias($interface, $singlyImplemented[$interface]) - ->setPublic(false); + + foreach ($this->interfaces as $interface) { + if (!empty($this->singlyImplemented[$interface]) && !$this->container->hasAlias($interface)) { + $this->container->setAlias($interface, $this->singlyImplemented[$interface])->setPublic(false); + $this->singlyImplementedAliases[$interface] = true; + } elseif ($this->singlyImplementedAliases[$interface] ?? false) { + $this->container->removeAlias($interface); } } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php index 033798f681..c7b55826da 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php @@ -63,6 +63,18 @@ class PhpFileLoader extends FileLoader return 'php' === $type; } + + public function resetBeforeConfiguringServices(): void + { + $this->interfaces = []; + $this->singlyImplemented = []; + $this->singlyImplementedAliases = []; + } + + public function removeSinglyImplementedAlias(string $alias): void + { + unset($this->singlyImplementedAliases[$alias]); + } } /** diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 50b90a81aa..996d11310e 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -66,6 +66,9 @@ class XmlFileLoader extends FileLoader $this->parseDefinitions($xml, $path, $defaults); } finally { $this->instanceof = []; + $this->interfaces = []; + $this->singlyImplemented = []; + $this->singlyImplementedAliases = []; } } @@ -194,6 +197,7 @@ class XmlFileLoader extends FileLoader $this->validateAlias($service, $file); $this->container->setAlias((string) $service->getAttribute('id'), $alias = new Alias($alias)); + unset($this->singlyImplementedAliases[(string) $service->getAttribute('id')]); if ($publicAttr = $service->getAttribute('public')) { $alias->setPublic(XmlUtils::phpize($publicAttr)); } elseif (isset($defaults['public'])) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index bb3868bdea..942c94d989 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -150,6 +150,9 @@ class YamlFileLoader extends FileLoader $this->parseDefinitions($content, $path); } finally { $this->instanceof = []; + $this->interfaces = []; + $this->singlyImplemented = []; + $this->singlyImplementedAliases = []; } } @@ -318,6 +321,7 @@ class YamlFileLoader extends FileLoader if (\is_string($service) && 0 === strpos($service, '@')) { $this->container->setAlias($id, $alias = new Alias(substr($service, 1))); + unset($this->singlyImplementedAliases[$id]); if (isset($defaults['public'])) { $alias->setPublic($defaults['public']); } @@ -341,6 +345,7 @@ class YamlFileLoader extends FileLoader if (isset($service['alias'])) { $this->container->setAlias($id, $alias = new Alias($service['alias'])); + unset($this->singlyImplementedAliases[$id]); if (\array_key_exists('public', $service)) { $alias->setPublic($service['public']); } elseif (isset($defaults['public'])) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/SinglyImplementedInterface/Adapter/Adapter.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/SinglyImplementedInterface/Adapter/Adapter.php new file mode 100644 index 0000000000..3450f0da87 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/SinglyImplementedInterface/Adapter/Adapter.php @@ -0,0 +1,9 @@ +tag('baz'); $di->load(Prototype::class.'\\', '../Prototype') ->autoconfigure() - ->exclude('../Prototype/{OtherDir,BadClasses}') + ->exclude('../Prototype/{OtherDir,BadClasses,SinglyImplementedInterface}') ->factory('f') ->deprecate('%service_id%') ->args([0]) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype_array.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype_array.php index 819a3fa11c..501baa3c10 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype_array.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype_array.php @@ -9,7 +9,7 @@ return function (ContainerConfigurator $c) { ->tag('baz'); $di->load(Prototype::class.'\\', '../Prototype') ->autoconfigure() - ->exclude(['../Prototype/OtherDir', '../Prototype/BadClasses']) + ->exclude(['../Prototype/OtherDir', '../Prototype/BadClasses', '../Prototype/SinglyImplementedInterface']) ->factory('f') ->deprecate('%service_id%') ->args([0]) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources.xml new file mode 100644 index 0000000000..ed533e917b --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.xml new file mode 100644 index 0000000000..e463cfc424 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.xml new file mode 100644 index 0000000000..29486267fc --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype.xml index 9d1d622d4a..1aa28bf341 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype.xml @@ -1,6 +1,6 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype_array.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype_array.xml index a62fd06eee..b24b3af577 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype_array.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype_array.xml @@ -4,6 +4,7 @@ ../Prototype/OtherDir ../Prototype/BadClasses + ../Prototype/SinglyImplementedInterface diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/singly_implemented_interface_in_multiple_resources.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/singly_implemented_interface_in_multiple_resources.xml new file mode 100644 index 0000000000..d4af42d525 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/singly_implemented_interface_in_multiple_resources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources.yml new file mode 100644 index 0000000000..ba8cf0d63f --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources.yml @@ -0,0 +1,12 @@ +services: + _defaults: + autowire: true + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Adapter\: + resource: ../Prototype/SinglyImplementedInterface/Adapter/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\AnotherAdapter\: + resource: ../Prototype/SinglyImplementedInterface/AnotherAdapter/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Port\: + resource: ../Prototype/SinglyImplementedInterface/Port/* diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.yml new file mode 100644 index 0000000000..76643879a2 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.yml @@ -0,0 +1,15 @@ +services: + _defaults: + autowire: true + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Port\PortInterface: + alias: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Adapter\Adapter + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Port\: + resource: ../Prototype/SinglyImplementedInterface/Port/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Adapter\: + resource: ../Prototype/SinglyImplementedInterface/Adapter/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\AnotherAdapter\: + resource: ../Prototype/SinglyImplementedInterface/AnotherAdapter/* diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.yml new file mode 100644 index 0000000000..2c9a9ccd48 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.yml @@ -0,0 +1,15 @@ +services: + _defaults: + autowire: true + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Port\: + resource: ../Prototype/SinglyImplementedInterface/Port/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Adapter\: + resource: ../Prototype/SinglyImplementedInterface/Adapter/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Port\PortInterface: + alias: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Adapter\Adapter + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\AnotherAdapter\: + resource: ../Prototype/SinglyImplementedInterface/AnotherAdapter/* diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_prototype.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_prototype.yml index 8c0b202aab..43f8d51e04 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_prototype.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_prototype.yml @@ -1,4 +1,4 @@ services: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\: resource: ../Prototype - exclude: '../Prototype/{OtherDir,BadClasses}' + exclude: '../Prototype/{OtherDir,BadClasses,SinglyImplementedInterface}' diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/singly_implemented_interface_in_multiple_resources.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/singly_implemented_interface_in_multiple_resources.yml new file mode 100644 index 0000000000..bc0eb0398c --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/singly_implemented_interface_in_multiple_resources.yml @@ -0,0 +1,9 @@ +services: + _defaults: + autowire: true + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Port\: + resource: ../Prototype/SinglyImplementedInterface/Port/* + + Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\SinglyImplementedInterface\Adapter\: + resource: ../Prototype/SinglyImplementedInterface/Adapter/* diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index dafa0464ed..3e00103aed 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -652,6 +652,7 @@ class XmlFileLoaderTest extends TestCase [ str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'OtherDir') => true, str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'BadClasses') => true, + str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'SinglyImplementedInterface') => true, ] ); $this->assertContains((string) $globResource, $resources); @@ -684,6 +685,7 @@ class XmlFileLoaderTest extends TestCase [ str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'BadClasses') => true, str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'OtherDir') => true, + str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'SinglyImplementedInterface') => true, ] ); $this->assertContains((string) $globResource, $resources); @@ -901,4 +903,50 @@ class XmlFileLoaderTest extends TestCase $this->assertSame('overridden', $container->get('bar')->quz); } + + public function testSinglyImplementedInterfacesInMultipleResources() + { + $container = new ContainerBuilder(); + + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('singly_implemented_interface_in_multiple_resources.xml'); + + $alias = $container->getAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class); + + $this->assertSame(Prototype\SinglyImplementedInterface\Adapter\Adapter::class, (string) $alias); + } + + public function testNotSinglyImplementedInterfacesInMultipleResources() + { + $container = new ContainerBuilder(); + + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('not_singly_implemented_interface_in_multiple_resources.xml'); + + $this->assertFalse($container->hasAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class)); + } + + public function testNotSinglyImplementedInterfacesInMultipleResourcesWithPreviouslyRegisteredAlias() + { + $container = new ContainerBuilder(); + + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.xml'); + + $alias = $container->getAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class); + + $this->assertSame(Prototype\SinglyImplementedInterface\Adapter\Adapter::class, (string) $alias); + } + + public function testNotSinglyImplementedInterfacesInMultipleResourcesWithPreviouslyRegisteredAlias2() + { + $container = new ContainerBuilder(); + + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.xml'); + + $alias = $container->getAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class); + + $this->assertSame(Prototype\SinglyImplementedInterface\Adapter\Adapter::class, (string) $alias); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index a7e56e6842..bc34b17428 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -415,6 +415,7 @@ class YamlFileLoaderTest extends TestCase false, [ str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'BadClasses') => true, str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'OtherDir') => true, + str_replace(\DIRECTORY_SEPARATOR, '/', $prototypeRealPath.\DIRECTORY_SEPARATOR.'SinglyImplementedInterface') => true, ] ); $this->assertContains((string) $globResource, $resources); @@ -834,4 +835,50 @@ class YamlFileLoaderTest extends TestCase $this->assertInstanceOf(TaggedIteratorArgument::class, $iteratorArgument); $this->assertNull($iteratorArgument->getIndexAttribute()); } + + public function testSinglyImplementedInterfacesInMultipleResources() + { + $container = new ContainerBuilder(); + + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('singly_implemented_interface_in_multiple_resources.yml'); + + $alias = $container->getAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class); + + $this->assertSame(Prototype\SinglyImplementedInterface\Adapter\Adapter::class, (string) $alias); + } + + public function testNotSinglyImplementedInterfacesInMultipleResources() + { + $container = new ContainerBuilder(); + + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('not_singly_implemented_interface_in_multiple_resources.yml'); + + $this->assertFalse($container->hasAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class)); + } + + public function testNotSinglyImplementedInterfacesInMultipleResourcesWithPreviouslyRegisteredAlias() + { + $container = new ContainerBuilder(); + + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias.yml'); + + $alias = $container->getAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class); + + $this->assertSame(Prototype\SinglyImplementedInterface\Adapter\Adapter::class, (string) $alias); + } + + public function testNotSinglyImplementedInterfacesInMultipleResourcesWithPreviouslyRegisteredAlias2() + { + $container = new ContainerBuilder(); + + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('not_singly_implemented_interface_in_multiple_resources_with_previously_registered_alias2.yml'); + + $alias = $container->getAlias(Prototype\SinglyImplementedInterface\Port\PortInterface::class); + + $this->assertSame(Prototype\SinglyImplementedInterface\Adapter\Adapter::class, (string) $alias); + } }