From 1939384f2aa8bcd947000113940c005072622d59 Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Thu, 14 Jan 2016 17:05:42 +0000 Subject: [PATCH 1/2] add a test for broken use case --- test/ServiceManagerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/ServiceManagerTest.php b/test/ServiceManagerTest.php index 716c9b91..31b9f445 100644 --- a/test/ServiceManagerTest.php +++ b/test/ServiceManagerTest.php @@ -245,6 +245,17 @@ public function testGetWithAlias() $this->assertEquals('bar', $this->serviceManager->get('baz')); } + /** + * @covers Zend\ServiceManager\ServiceManager::get + */ + public function testGetWithAliasofAliasWithCanonicalizedName() + { + $this->serviceManager->setService('Foo', 'Bar'); + $this->serviceManager->setAlias('Baz', 'Foo'); + $this->serviceManager->setAlias('Qux', 'Baz'); + $this->assertEquals('Bar', $this->serviceManager->get('Qux')); + } + /** * @covers Zend\ServiceManager\ServiceManager::get */ From d01978aaeeb20a0b08aac8603617fe833653d9bf Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Thu, 14 Jan 2016 17:15:10 +0000 Subject: [PATCH 2/2] canonicalize the alias name when retrieving the key from the aliases array --- src/ServiceManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 89ce2ad0..91cf5ac9 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -477,7 +477,7 @@ protected function resolveAlias($cName) } $stack[$cName] = $cName; - $cName = $this->aliases[$cName]; + $cName = $this->aliases[$this->canonicalizeName($cName)]; } return $cName;