Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1272b6a

Browse files
[DI] Dont tell about autoregistration in strict autowiring mode
1 parent 7af20bc commit 1272b6a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
285285
return $reference;
286286
}
287287

288-
if (null === $this->types) {
288+
if (!$this->strictMode && null === $this->types) {
289289
$this->populateAvailableTypes();
290290
}
291291

@@ -479,12 +479,15 @@ private function createTypeAlternatives(TypedReference $reference)
479479
if ($message = $this->getAliasesSuggestionForType($type = $reference->getType())) {
480480
return ' '.$message;
481481
}
482+
if (null === $this->types) {
483+
$this->populateAvailableTypes();
484+
}
482485

483486
if (isset($this->ambiguousServiceTypes[$type])) {
484487
$message = sprintf('one of these existing services: "%s"', implode('", "', $this->ambiguousServiceTypes[$type]));
485488
} elseif (isset($this->types[$type])) {
486489
$message = sprintf('the existing "%s" service', $this->types[$type]);
487-
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered()) {
490+
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered() && !$this->strictMode) {
488491
return ' It cannot be auto-registered because it is from a different root namespace.';
489492
} else {
490493
return;

0 commit comments

Comments
 (0)