@@ -191,8 +191,11 @@ so, here's the advantages of immutable-setters:
191
191
* Your service becomes immutable, as the container will return a new object,
192
192
the initial service stays clean and unchanged.
193
193
194
- * You can easily change the injected service as long as it respect the interface/type
195
- asked by the initial service.
194
+ * This type of injection works well with traits as the service can be composed,
195
+ this way, adapting the service to your application requirements is easier.
196
+
197
+ * The setter can be called multiple times, this way, adding a dependency to a collection
198
+ becomes easier and allows you to add a variable number of dependencies.
196
199
197
200
The disadvantages are:
198
201
@@ -204,8 +207,8 @@ The disadvantages are:
204
207
you can found that adding docblock for a single method isn't adapted or
205
208
link your code to the container.
206
209
207
- * As this approach force the container to create a new object
208
- once the method is called, you can found hard to debug and test your code.
210
+ * Unless the service is declared lazy, it is incompatible with services
211
+ that reference each other in what are called circular loops
209
212
210
213
Setter Injection
211
214
----------------
@@ -278,6 +281,9 @@ This time the advantages are:
278
281
the method adds the dependency to a collection. You can then have a variable
279
282
number of dependencies.
280
283
284
+ * Like the immutable-setter one, this type of injection works well with
285
+ traits and allows you to compose your service.
286
+
281
287
The disadvantages of setter injection are:
282
288
283
289
* The setter can be called more than just at the time of construction so
0 commit comments