From ae73b1b3affd9c4e3031fb88c84a7082368ca6c3 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Fri, 8 Jun 2018 17:19:09 -0400 Subject: [PATCH 1/4] Avoid undefined variable notices. --- src/AbstractPluginManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AbstractPluginManager.php b/src/AbstractPluginManager.php index 7e40a2d0..087df5a2 100644 --- a/src/AbstractPluginManager.php +++ b/src/AbstractPluginManager.php @@ -355,6 +355,8 @@ protected function createServiceViaCallback($callable, $cName, $rName) } elseif (is_array($callable)) { // reset both rewinds and returns the value of the first array element $factory = reset($callable); + } else { + $factory = null; } if ($factory instanceof Factory\InvokableFactory) { From cf703e8251ce2fed8da6edf55960dc19f8c32367 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Fri, 8 Jun 2018 17:49:34 -0400 Subject: [PATCH 2/4] Tests for preceding fix. --- test/AbstractPluginManagerTest.php | 10 ++++++++++ test/TestAsset/FooStaticFactory.php | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/TestAsset/FooStaticFactory.php diff --git a/test/AbstractPluginManagerTest.php b/test/AbstractPluginManagerTest.php index 45ba1b48..8ddaa4a3 100644 --- a/test/AbstractPluginManagerTest.php +++ b/test/AbstractPluginManagerTest.php @@ -437,6 +437,16 @@ public function testV2v3PluginManager() $this->assertInstanceOf(InvokableObject::class, $pluginManager->get('foo')); } + public function testStaticFactoryMethod() + { + $pluginManager = new FooPluginManager(new Config([ + 'factories' => [ + 'Foo' => 'ZendTest\ServiceManager\TestAsset\FooStaticFactory::createService', + ], + ])); + $this->assertInstanceOf(TestAsset\Foo::class, $pluginManager->get('foo')); + } + public function testInvokableFactoryHasMutableOptions() { $pluginManager = new FooPluginManager($this->serviceManager); diff --git a/test/TestAsset/FooStaticFactory.php b/test/TestAsset/FooStaticFactory.php new file mode 100644 index 00000000..ca6b1e61 --- /dev/null +++ b/test/TestAsset/FooStaticFactory.php @@ -0,0 +1,18 @@ + Date: Fri, 8 Jun 2018 17:57:58 -0400 Subject: [PATCH 3/4] Update CHANGELOG. --- CHANGELOG.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cf142c0..9dd2f6e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,30 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 2.7.11 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#269](https://github.com/zendframework/zend-servicemanager/pull/269) fixes a + regression whereby using static Callable strings caused an undefined variable + notice. + ## 2.7.10 - 2017-12-05 ### Added From b660ae23198c2618fabb3025d54f39d5624177c2 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Fri, 22 Jun 2018 10:36:05 -0400 Subject: [PATCH 4/4] Update FooStaticFactory.php --- test/TestAsset/FooStaticFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestAsset/FooStaticFactory.php b/test/TestAsset/FooStaticFactory.php index ca6b1e61..0693de55 100644 --- a/test/TestAsset/FooStaticFactory.php +++ b/test/TestAsset/FooStaticFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */