From b657fcc30f7f82d0c7282a56a578425218f75ecf Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 1 Jul 2018 21:23:29 +0700 Subject: [PATCH] move $initializer variable definition only when there is $this->servicesMap[$name] at LazyServiceFactory --- src/Proxy/LazyServiceFactory.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Proxy/LazyServiceFactory.php b/src/Proxy/LazyServiceFactory.php index 838740c5..0b806d6f 100644 --- a/src/Proxy/LazyServiceFactory.php +++ b/src/Proxy/LazyServiceFactory.php @@ -49,14 +49,14 @@ public function __construct(LazyLoadingValueHolderFactory $proxyFactory, array $ */ public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) { - $initializer = function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($callback) { - $proxy->setProxyInitializer(null); - $wrappedInstance = $callback(); + if (isset($this->servicesMap[$name])) { + $initializer = function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($callback) { + $proxy->setProxyInitializer(null); + $wrappedInstance = $callback(); - return true; - }; + return true; + }; - if (isset($this->servicesMap[$name])) { return $this->proxyFactory->createProxy($this->servicesMap[$name], $initializer); }