minor #21605 [DI] Align AutowirePass with 2.8 (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

[DI] Align AutowirePass with 2.8

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Follow up a less than ideal [merge conflict resolution](https://github.com/symfony/symfony/pull/18691#issuecomment-218803903), found while reviewing AutowirePass in 2.8 and 3.2 and wondering about the delta. Should reduce future merge conflicts and help history tracking.

Commits
-------

dd5236a [DI] Align AutowirePass with 2.8
This commit is contained in:
Nicolas Grekas 2017-02-14 13:24:27 +01:00
commit 28a3524a0e

View File

@ -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
*