@@ -24,6 +24,7 @@ the alphabet.
2424
2525Start by creating a ROT13 transformer class::
2626
27+ // src/Util/Rot13Transformer.php
2728 namespace App\Util;
2829
2930 class Rot13Transformer
@@ -36,6 +37,7 @@ Start by creating a ROT13 transformer class::
3637
3738And now a Twitter client using this transformer::
3839
40+ // src/Service/TwitterClient.php
3941 namespace App\Service;
4042
4143 use App\Util\Rot13Transformer;
@@ -122,6 +124,7 @@ both services:
122124
123125 Now, you can use the ``TwitterClient `` service immediately in a controller::
124126
127+ // src/Controller/DefaultController.php
125128 namespace App\Controller;
126129
127130 use App\Service\TwitterClient;
@@ -153,6 +156,9 @@ Autowiring Logic Explained
153156
154157Autowiring works by reading the ``Rot13Transformer `` *type-hint * in ``TwitterClient ``::
155158
159+ // src/Service/TwitterClient.php
160+ namespace App\Service;
161+
156162 // ...
157163 use App\Util\Rot13Transformer;
158164
@@ -272,6 +278,7 @@ of concrete classes as it replaces your dependencies with other objects.
272278
273279To follow this best practice, suppose you decide to create a ``TransformerInterface ``::
274280
281+ // src/Util/TransformerInterface.php
275282 namespace App\Util;
276283
277284 interface TransformerInterface
@@ -371,6 +378,7 @@ Dealing with Multiple Implementations of the Same Type
371378Suppose you create a second class - ``UppercaseTransformer `` that implements
372379``TransformerInterface ``::
373380
381+ // src/Util/UppercaseTransformer.php
374382 namespace App\Util;
375383
376384 class UppercaseTransformer implements TransformerInterface
@@ -399,6 +407,7 @@ create a *named autowiring alias* from a special string containing the
399407interface followed by a variable name matching the one you use when doing
400408the injection::
401409
410+ // src/Service/MastodonClient.php
402411 namespace App\Service;
403412
404413 use App\Util\TransformerInterface;
@@ -537,6 +546,7 @@ When autowiring is enabled for a service, you can *also* configure the container
537546to call methods on your class when it's instantiated. For example, suppose you want
538547to inject the ``logger `` service, and decide to use setter-injection::
539548
549+ // src/Util/Rot13Transformer.php
540550 namespace App\Util;
541551
542552 class Rot13Transformer
0 commit comments