diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index fcb986383c..985f3a50e1 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -217,26 +217,24 @@ class AutowirePass implements CompilerPassInterface // is this already a type/class that is known to match multiple services? if (isset($this->ambiguousServiceTypes[$type])) { - $this->addServiceToAmbiguousType($id, $type); + $this->ambiguousServiceTypes[$type][] = $id; return; } // check to make sure the type doesn't match multiple services - if (isset($this->types[$type])) { - if ($this->types[$type] === $id) { - return; - } - - // keep an array of all services matching this type - $this->addServiceToAmbiguousType($id, $type); - - unset($this->types[$type]); + if (!isset($this->types[$type]) || $this->types[$type] === $id) { + $this->types[$type] = $id; return; } - $this->types[$type] = $id; + // keep an array of all services matching this type + if (!isset($this->ambiguousServiceTypes[$type])) { + $this->ambiguousServiceTypes[$type] = array($this->types[$type]); + unset($this->types[$type]); + } + $this->ambiguousServiceTypes[$type][] = $id; } /** @@ -311,17 +309,6 @@ class AutowirePass implements CompilerPassInterface return $this->reflectionClasses[$id] = $reflector; } - private function addServiceToAmbiguousType($id, $type) - { - // keep an array of all services matching this type - if (!isset($this->ambiguousServiceTypes[$type])) { - $this->ambiguousServiceTypes[$type] = array( - $this->types[$type], - ); - } - $this->ambiguousServiceTypes[$type][] = $id; - } - /** * @param \ReflectionClass $reflectionClass *