Mercurial > hg > cmmr2012-drupal-site
diff vendor/symfony/dependency-injection/ServiceLocator.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/vendor/symfony/dependency-injection/ServiceLocator.php Thu Feb 28 11:14:44 2019 +0000 +++ b/vendor/symfony/dependency-injection/ServiceLocator.php Thu Feb 28 13:11:55 2019 +0000 @@ -22,7 +22,7 @@ class ServiceLocator implements PsrContainerInterface { private $factories; - private $loading = array(); + private $loading = []; private $externalId; private $container; @@ -48,12 +48,12 @@ public function get($id) { if (!isset($this->factories[$id])) { - throw new ServiceNotFoundException($id, end($this->loading) ?: null, null, array(), $this->createServiceNotFoundMessage($id)); + throw new ServiceNotFoundException($id, end($this->loading) ?: null, null, [], $this->createServiceNotFoundMessage($id)); } if (isset($this->loading[$id])) { $ids = array_values($this->loading); - $ids = array_slice($this->loading, array_search($id, $ids)); + $ids = \array_slice($this->loading, array_search($id, $ids)); $ids[] = $id; throw new ServiceCircularReferenceException($id, $ids); @@ -91,42 +91,43 @@ } $class = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 3); - $class = isset($class[2]['object']) ? get_class($class[2]['object']) : null; + $class = isset($class[2]['object']) ? \get_class($class[2]['object']) : null; $externalId = $this->externalId ?: $class; - $msg = sprintf('Service "%s" not found: ', $id); + $msg = []; + $msg[] = sprintf('Service "%s" not found:', $id); if (!$this->container) { $class = null; } elseif ($this->container->has($id) || isset($this->container->getRemovedIds()[$id])) { - $msg .= 'even though it exists in the app\'s container, '; + $msg[] = 'even though it exists in the app\'s container,'; } else { try { $this->container->get($id); $class = null; } catch (ServiceNotFoundException $e) { if ($e->getAlternatives()) { - $msg .= sprintf(' did you mean %s? Anyway, ', $this->formatAlternatives($e->getAlternatives(), 'or')); + $msg[] = sprintf('did you mean %s? Anyway,', $this->formatAlternatives($e->getAlternatives(), 'or')); } else { $class = null; } } } if ($externalId) { - $msg .= sprintf('the container inside "%s" is a smaller service locator that %s', $externalId, $this->formatAlternatives()); + $msg[] = sprintf('the container inside "%s" is a smaller service locator that %s', $externalId, $this->formatAlternatives()); } else { - $msg .= sprintf('the current service locator %s', $this->formatAlternatives()); + $msg[] = sprintf('the current service locator %s', $this->formatAlternatives()); } if (!$class) { // no-op } elseif (is_subclass_of($class, ServiceSubscriberInterface::class)) { - $msg .= sprintf(' Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "%s::getSubscribedServices()".', preg_replace('/([^\\\\]++\\\\)++/', '', $class)); + $msg[] = sprintf('Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "%s::getSubscribedServices()".', preg_replace('/([^\\\\]++\\\\)++/', '', $class)); } else { - $msg .= 'Try using dependency injection instead.'; + $msg[] = 'Try using dependency injection instead.'; } - return $msg; + return implode(' ', $msg); } private function formatAlternatives(array $alternatives = null, $separator = 'and') @@ -136,7 +137,7 @@ if (!$alternatives = array_keys($this->factories)) { return 'is empty...'; } - $format = sprintf('only knows about the %s service%s.', $format, 1 < count($alternatives) ? 's' : ''); + $format = sprintf('only knows about the %s service%s.', $format, 1 < \count($alternatives) ? 's' : ''); } $last = array_pop($alternatives);