Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/dependency-injection/Compiler/AutowirePass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children | af1871eacc83 |
line wrap: on
line diff
--- a/vendor/symfony/dependency-injection/Compiler/AutowirePass.php Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/symfony/dependency-injection/Compiler/AutowirePass.php Thu Feb 28 13:21:36 2019 +0000 @@ -28,13 +28,13 @@ */ class AutowirePass extends AbstractRecursivePass { - private $definedTypes = array(); + private $definedTypes = []; private $types; private $ambiguousServiceTypes; - private $autowired = array(); + private $autowired = []; private $lastFailure; private $throwOnAutowiringException; - private $autowiringExceptions = array(); + private $autowiringExceptions = []; private $strictMode; /** @@ -63,16 +63,16 @@ public function process(ContainerBuilder $container) { // clear out any possibly stored exceptions from before - $this->autowiringExceptions = array(); + $this->autowiringExceptions = []; $this->strictMode = $container->hasParameter('container.autowiring.strict_mode') && $container->getParameter('container.autowiring.strict_mode'); try { parent::process($container); } finally { - $this->definedTypes = array(); + $this->definedTypes = []; $this->types = null; $this->ambiguousServiceTypes = null; - $this->autowired = array(); + $this->autowired = []; } } @@ -89,7 +89,7 @@ { @trigger_error('The '.__METHOD__.'() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.', E_USER_DEPRECATED); - $metadata = array(); + $metadata = []; foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { if (!$reflectionMethod->isStatic()) { @@ -147,7 +147,7 @@ } if ($constructor) { - array_unshift($methodCalls, array($constructor, $value->getArguments())); + array_unshift($methodCalls, [$constructor, $value->getArguments()]); } $methodCalls = $this->autowireCalls($reflectionClass, $methodCalls); @@ -327,9 +327,9 @@ */ private function populateAvailableTypes($onlyAutowiringTypes = false) { - $this->types = array(); + $this->types = []; if (!$onlyAutowiringTypes) { - $this->ambiguousServiceTypes = array(); + $this->ambiguousServiceTypes = []; } foreach ($this->container->getDefinitions() as $id => $definition) { @@ -401,7 +401,7 @@ // keep an array of all services matching this type if (!isset($this->ambiguousServiceTypes[$type])) { - $this->ambiguousServiceTypes[$type] = array($this->types[$type]); + $this->ambiguousServiceTypes[$type] = [$this->types[$type]]; unset($this->types[$type]); } $this->ambiguousServiceTypes[$type][] = $id; @@ -452,7 +452,17 @@ private function createTypeNotFoundMessage(TypedReference $reference, $label) { - if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) { + $trackResources = $this->container->isTrackingResources(); + $this->container->setResourceTracking(false); + try { + if ($r = $this->container->getReflectionClass($type = $reference->getType(), false)) { + $alternatives = $this->createTypeAlternatives($reference); + } + } finally { + $this->container->setResourceTracking($trackResources); + } + + if (!$r) { // either $type does not exist or a parent class does not exist try { $resource = new ClassExistenceResource($type, false); @@ -465,7 +475,6 @@ $message = sprintf('has type "%s" but this class %s.', $type, $parentMsg ? sprintf('is missing a parent class (%s)', $parentMsg) : 'was not found'); } else { - $alternatives = $this->createTypeAlternatives($reference); $message = $this->container->has($type) ? 'this service is abstract' : 'no such service exists'; $message = sprintf('references %s "%s" but %s.%s', $r->isInterface() ? 'interface' : 'class', $type, $message, $alternatives); @@ -512,7 +521,7 @@ */ private static function getResourceMetadataForMethod(\ReflectionMethod $method) { - $methodArgumentsMetadata = array(); + $methodArgumentsMetadata = []; foreach ($method->getParameters() as $parameter) { try { $class = $parameter->getClass(); @@ -522,11 +531,11 @@ } $isVariadic = method_exists($parameter, 'isVariadic') && $parameter->isVariadic(); - $methodArgumentsMetadata[] = array( + $methodArgumentsMetadata[] = [ 'class' => $class, 'isOptional' => $parameter->isOptional(), 'defaultValue' => ($parameter->isOptional() && !$isVariadic) ? $parameter->getDefaultValue() : null, - ); + ]; } return $methodArgumentsMetadata; @@ -534,7 +543,7 @@ private function getAliasesSuggestionForType($type, $extraContext = null) { - $aliases = array(); + $aliases = []; foreach (class_parents($type) + class_implements($type) as $parent) { if ($this->container->has($parent) && !$this->container->findDefinition($parent)->isAbstract()) { $aliases[] = $parent; @@ -542,7 +551,7 @@ } $extraContext = $extraContext ? ' '.$extraContext : ''; - if (1 < $len = count($aliases)) { + if (1 < $len = \count($aliases)) { $message = sprintf('Try changing the type-hint%s to one of its parents: ', $extraContext); for ($i = 0, --$len; $i < $len; ++$i) { $message .= sprintf('%s "%s", ', class_exists($aliases[$i], false) ? 'class' : 'interface', $aliases[$i]);