Skip to content

Commit 3d5a111

Browse files
[DI] Cleanup remaings from autoregistration
1 parent 1f119cc commit 3d5a111

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class AutowirePass extends AbstractRecursivePass
2929
{
3030
private $types;
3131
private $ambiguousServiceTypes = array();
32-
private $autowired = array();
3332
private $lastFailure;
3433
private $throwOnAutowiringException;
3534

@@ -48,7 +47,6 @@ public function process(ContainerBuilder $container)
4847
} finally {
4948
$this->types = null;
5049
$this->ambiguousServiceTypes = array();
51-
$this->autowired = array();
5250
}
5351
}
5452

@@ -232,22 +230,6 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
232230
if ($type !== (string) $reference || ($this->container->has($type) && !$this->container->findDefinition($type)->isAbstract())) {
233231
return $reference;
234232
}
235-
236-
if (!$reference->canBeAutoregistered()) {
237-
return;
238-
}
239-
240-
if (null === $this->types) {
241-
$this->populateAvailableTypes();
242-
}
243-
244-
if (isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) {
245-
return;
246-
}
247-
248-
if (isset($this->autowired[$type])) {
249-
return $this->autowired[$type] ? new TypedReference($this->autowired[$type], $type) : null;
250-
}
251233
}
252234

253235
/**
@@ -351,6 +333,9 @@ private function createTypeAlternatives(TypedReference $reference)
351333
if ($message = $this->getAliasesSuggestionForType($type = $reference->getType())) {
352334
return ' '.$message;
353335
}
336+
if (null === $this->types) {
337+
$this->populateAvailableTypes();
338+
}
354339

355340
$servicesAndAliases = $this->container->getServiceIds();
356341
if (!$this->container->has($type) && false !== $key = array_search(strtolower($type), array_map('strtolower', $servicesAndAliases))) {
@@ -359,8 +344,6 @@ private function createTypeAlternatives(TypedReference $reference)
359344
$message = sprintf('one of these existing services: "%s"', implode('", "', $this->ambiguousServiceTypes[$type]));
360345
} elseif (isset($this->types[$type])) {
361346
$message = sprintf('the existing "%s" service', $this->types[$type]);
362-
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered()) {
363-
return ' It cannot be auto-registered because it is from a different root namespace.';
364347
} else {
365348
return;
366349
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ public function provideNotWireableCalls()
697697
{
698698
return array(
699699
array('setNotAutowireable', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setNotAutowireable()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotARealClass" but this class was not found.'),
700-
array('setDifferentNamespace', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setDifferentNamespace()" references class "stdClass" but no such service exists. It cannot be auto-registered because it is from a different root namespace.'),
700+
array('setDifferentNamespace', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setDifferentNamespace()" references class "stdClass" but no such service exists.'),
701701
array(null, 'Invalid service "foo": method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setProtectedMethod()" must be public.'),
702702
);
703703
}

0 commit comments

Comments
 (0)