@@ -34,6 +34,7 @@ class AutowirePass extends AbstractRecursivePass
34
34
private $ lastFailure ;
35
35
private $ throwOnAutowiringException ;
36
36
private $ autowiringExceptions = array ();
37
+ private $ strictMode ;
37
38
38
39
/**
39
40
* @param bool $throwOnAutowireException Errors can be retrieved via Definition::getErrors()
@@ -62,6 +63,7 @@ public function process(ContainerBuilder $container)
62
63
{
63
64
// clear out any possibly stored exceptions from before
64
65
$ this ->autowiringExceptions = array ();
66
+ $ this ->strictMode = $ container ->hasParameter ('container.autowiring.strict_mode ' ) && $ container ->getParameter ('container.autowiring.strict_mode ' );
65
67
66
68
try {
67
69
parent ::process
C918
($ container );
@@ -290,7 +292,7 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
290
292
return new TypedReference ($ this ->types [$ type ], $ type );
291
293
}
292
294
293
- if (isset ($ this ->types [$ type ])) {
295
+ if (! $ this -> strictMode && isset ($ this ->types [$ type ])) {
294
296
$ message = 'Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won \'t be supported in version 4.0. ' ;
295
297
if ($ aliasSuggestion = $ this ->getAliasesSuggestionForType ($ type = $ reference ->getType (), $ deprecationMessage )) {
296
298
$ message .= ' ' .$ aliasSuggestion ;
@@ -311,7 +313,9 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
311
313
return $ this ->autowired [$ type ] ? new TypedReference ($ this ->autowired [$ type ], $ type ) : null ;
312
314
}
313
315
314
- return $ this ->createAutowiredDefinition ($ type );
316
+ if (!$ this ->strictMode ) {
317
+ return $ this ->createAutowiredDefinition ($ type );
318
+ }
315
319
}
316
320
317
321
/**
0 commit comments