8000 [DI] Align AutowirePass with 2.8 · symfony/symfony@dd5236a · GitHub
[go: up one dir, main page]

Skip to content

Commit dd5236a

Browse files
[DI] Align AutowirePass with 2.8
1 parent 50be214 commit dd5236a

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,24 @@ private function set($type, $id)
217217

218218
// is this already a type/class that is known to match multiple services?
219219
if (isset($this->ambiguousServiceTypes[$type])) {
220-
$this->addServiceToAmbiguousType($id, $type);
220+
$this->ambiguousServiceTypes[$type][] = $id;
221221

222222
return;
223223
}
224224

225225
// check to make sure the type doesn't match multiple services
226-
if (isset($this->types[$type])) {
227-
if ($this->types[$type] === $id) {
228-
return;
229-
}
230-
231-
// keep an array of all services matching this type
232-
$this->addServiceToAmbiguousType($id, $type);
233-
234-
unset($this->types[$type]);
226+
if (!isset($this->types[$type]) || $this->types[$type] === $id) {
227+
$this->types[$type] = $id;
235228

236229
return;
237230
}
238231

239-
$this->types[$type] = $id;
232+
// keep an array of all services matching this type
233+
if (!isset($this->ambiguousServiceTypes[$type])) {
234+
$this->ambiguousServiceTypes[$type] = array($this->types[$type]);
235+
unset($this->types[$type]);
236+
}
237+
$this->ambiguousServiceTypes[$type][] = $id;
240238
}
241239

242240
/**
@@ -311,17 +309,6 @@ private function getReflectionClass($id, Definition $definition)
311309
return $this->reflectionClasses[$id] = $reflector;
312310
}
313311

314-
private function addServiceToAmbiguousType($id, $type)
315-
{
316-
// keep an array of all services matching this type
317-
if (!isset($this->ambiguousServiceTypes[$type])) {
318-
$this->ambiguousServiceTypes[$type] = array(
319-
$this->types[$type],
320-
);
321-
}
322-
$this->ambiguousServiceTypes[$type][] = $id;
323-
}
324-
325312
/**
326313
* @param \ReflectionClass $reflectionClass
327314
*

0 commit comments

Comments
 (0)
0