From 6241e596b02a31ab478745842b8ea588b19574ab Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Wed, 13 Jul 2016 00:37:30 +0200 Subject: [PATCH 1/4] Cannot use Zend\ServiceManager\Initializer\InitializerInterface as InitializerInterface because the name is already in use in `ServiceManager.php` on line 27 --- src/ServiceManager.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 8f626c79..3658bcae 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -24,7 +24,7 @@ use Zend\ServiceManager\Exception\ServiceNotFoundException; use Zend\ServiceManager\Factory\AbstractFactoryInterface; use Zend\ServiceManager\Factory\DelegatorFactoryInterface; -use Zend\ServiceManager\Initializer\InitializerInterface; +use Zend\ServiceManager\Initializer\InitializerInterface as InitializerInitializerInterface; /** * Service Manager. @@ -82,7 +82,7 @@ class ServiceManager implements ServiceLocatorInterface protected $factories = []; /** - * @var InitializerInterface[] + * @var InitializerInitializerInterface[] */ protected $initializers = []; @@ -475,7 +475,7 @@ public function addDelegator($name, $factory) /** * Add an initializer. * - * @param string|callable|InitializerInterface $initializer + * @param string|callable|InitializerInitializerInterface $initializer */ public function addInitializer($initializer) { @@ -553,7 +553,7 @@ private function resolveAbstractFactories(array $abstractFactories) /** * Instantiate initializers for to avoid checks during service construction. * - * @param string[]|callable[]|InitializerInterface[] $initializers + * @param string[]|callable[]|InitializerInitializerInterface[] $initializers * * @return void */ @@ -578,7 +578,7 @@ private function resolveInitializers(array $initializers) 'which does not exist; please provide a valid function name or class ' . 'name resolving to an implementation of %s', $initializer, - InitializerInterface::class + InitializerInitializerInterface::class ) ); } @@ -589,7 +589,7 @@ private function resolveInitializers(array $initializers) 'An invalid initializer was registered. Expected a callable, or an instance of ' . '(or string class name resolving to) "%s", ' . 'but "%s" was received', - InitializerInterface::class, + InitializerInitializerInterface::class, (is_object($initializer) ? get_class($initializer) : gettype($initializer)) ) ); From 408a6f87c69440878ea46172c312c125d99de352 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Wed, 13 Jul 2016 20:35:21 +0200 Subject: [PATCH 2/4] InitializerInitializerInterface changed to Initializer\InitializerInterface --- src/ServiceManager.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 3658bcae..d85feadf 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -24,7 +24,7 @@ use Zend\ServiceManager\Exception\ServiceNotFoundException; use Zend\ServiceManager\Factory\AbstractFactoryInterface; use Zend\ServiceManager\Factory\DelegatorFactoryInterface; -use Zend\ServiceManager\Initializer\InitializerInterface as InitializerInitializerInterface; +use Zend\ServiceManager\Initializer; /** * Service Manager. @@ -82,7 +82,7 @@ class ServiceManager implements ServiceLocatorInterface protected $factories = []; /** - * @var InitializerInitializerInterface[] + * @var Initializer\InitializerInterface[] */ protected $initializers = []; @@ -475,7 +475,7 @@ public function addDelegator($name, $factory) /** * Add an initializer. * - * @param string|callable|InitializerInitializerInterface $initializer + * @param string|callable|Initializer\InitializerInterface $initializer */ public function addInitializer($initializer) { @@ -553,7 +553,7 @@ private function resolveAbstractFactories(array $abstractFactories) /** * Instantiate initializers for to avoid checks during service construction. * - * @param string[]|callable[]|InitializerInitializerInterface[] $initializers + * @param string[]|callable[]|Initializer\InitializerInterface[] $initializers * * @return void */ @@ -578,7 +578,7 @@ private function resolveInitializers(array $initializers) 'which does not exist; please provide a valid function name or class ' . 'name resolving to an implementation of %s', $initializer, - InitializerInitializerInterface::class + Initializer\InitializerInterface::class ) ); } @@ -589,7 +589,7 @@ private function resolveInitializers(array $initializers) 'An invalid initializer was registered. Expected a callable, or an instance of ' . '(or string class name resolving to) "%s", ' . 'but "%s" was received', - InitializerInitializerInterface::class, + Initializer\InitializerInterface::class, (is_object($initializer) ? get_class($initializer) : gettype($initializer)) ) ); From c9a86609632c95cd04a74bff8b8e1942da71635f Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 15 Jul 2016 09:57:44 -0500 Subject: [PATCH 3/4] Remove conflicting imports and resolve relative to root namespace - No need to import Zend\ServiceManager\Initializer; it's a subnamespace of the current namespace already. - Resolve AbstractFactoryInterface and DelegatorFactoryInterface relative to `Factory` subnamespace to prevent naming collisions. These only affect docblocks anyways. (Fixes issues observed in two separate, 3rd party packages when testing against the class.) --- src/ServiceManager.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ServiceManager.php b/src/ServiceManager.php index d85feadf..0b72309a 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -22,9 +22,6 @@ use Zend\ServiceManager\Exception\InvalidArgumentException; use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotFoundException; -use Zend\ServiceManager\Factory\AbstractFactoryInterface; -use Zend\ServiceManager\Factory\DelegatorFactoryInterface; -use Zend\ServiceManager\Initializer; /** * Service Manager. @@ -44,7 +41,7 @@ class ServiceManager implements ServiceLocatorInterface { /** - * @var AbstractFactoryInterface[] + * @var Factory\AbstractFactoryInterface[] */ protected $abstractFactories = []; @@ -70,7 +67,7 @@ class ServiceManager implements ServiceLocatorInterface protected $creationContext; /** - * @var string[][]|DelegatorFactoryInterface[][] + * @var string[][]|Factory\DelegatorFactoryInterface[][] */ protected $delegators = []; @@ -507,7 +504,7 @@ public function setShared($name, $flag) /** * Instantiate abstract factories for to avoid checks during service construction. * - * @param string[]|AbstractFactoryInterface[] $abstractFactories + * @param string[]|Factory\AbstractFactoryInterface[] $abstractFactories * * @return void */ @@ -518,7 +515,7 @@ private function resolveAbstractFactories(array $abstractFactories) $abstractFactory = new $abstractFactory(); } - if ($abstractFactory instanceof AbstractFactoryInterface) { + if ($abstractFactory instanceof Factory\AbstractFactoryInterface) { $this->abstractFactories[] = $abstractFactory; continue; } From 4404d4e5032c917b379d26c8c3af967121214b72 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 15 Jul 2016 09:59:37 -0500 Subject: [PATCH 4/4] Added CHANGELOG for #136 --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a7afc4f..a5209a89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 3.1.1 - TBD +## 3.1.1 - 2016-07-15 ### Added @@ -18,7 +18,10 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#136](https://github.com/zendframework/zend-servicemanager/pull/136) removes + several imports to classes in subnamespaces within the `ServiceManager` + classfile, removing potential name resolution conflicts that occurred in edge + cases when testing. ## 3.1.0 - 2016-06-01