From 000d8689dcdb91a352dfaa84efac4dcbf8dc80db Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 23 Oct 2013 14:08:35 -0500 Subject: [PATCH] [zendframework/zf2#5293] review - do not call initializers if we have a null value --- src/ServiceManager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 2631d63d..2480eeb5 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -617,6 +617,11 @@ public function doCreate($rName, $cName) )); } + // Do not call initializers if we do not have an instance + if ($instance === null) { + return $instance; + } + foreach ($this->initializers as $initializer) { if ($initializer instanceof InitializerInterface) { $initializer->initialize($instance, $this);