Skip to content

Commit 7b85a18

Browse files
authored
Update autowiring.rst
ref.: symfony/symfony#29028
1 parent 60c4d98 commit 7b85a18

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

service_container/autowiring.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@ Thanks to the ``App\Util\TransformerInterface`` alias, the autowiring subsystem
341341
knows that the ``App\Util\Rot13Transformer`` service should be injected when
342342
dealing with the ``TransformerInterface``.
343343

344+
.. tip::
345+
346+
As long as you have only one concrete implementation of an interface under same
347+
namespace, alias is not mandatory and autowire will work injecting the concrete
348+
implementation even without alias definition.
349+
Neverthless is recommended to provide an alias in order to preserve application logic
350+
when a second concrete implementation kicks in, otherwise compiler compilation would
351+
throw an exception.
352+
344353
Dealing with Multiple Implementations of the Same Type
345354
------------------------------------------------------
346355

0 commit comments

Comments
 (0)