[DI] use try-finally for container

This commit is contained in:
Tobias Schultze 2015-11-26 17:15:31 +01:00
parent 5183c881d0
commit 1ab73166a7

View File

@ -272,17 +272,13 @@ class Container implements ResettableContainerInterface
try { try {
$service = $this->$method(); $service = $this->$method();
} catch (\Exception $e) { } catch (\Exception $e) {
unset($this->loading[$id]); unset($this->services[$id]);
if (array_key_exists($id, $this->services)) {
unset($this->services[$id]);
}
throw $e; throw $e;
} finally {
unset($this->loading[$id]);
} }
unset($this->loading[$id]);
return $service; return $service;
} }
} }