diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 2bd3872a..5963093d 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -569,10 +569,15 @@ private function resolveInitializers(array $initializers) private function resolveAliases(array $aliases) { foreach ($aliases as $alias => $service) { - $name = $alias; + // avoiding infinite loops by removing already resolved aliases + $currentAliases = $this->aliases; + $name = $alias; - while (isset($this->aliases[$name])) { - $name = $this->aliases[$name]; + while (isset($currentAliases[$name])) { + $oldName = $name; + $name = $currentAliases[$name]; + + unset($currentAliases[$oldName]); } $this->resolvedAliases[$alias] = $name;