Skip to content

Commit 9654bed

Browse files
committed
[Types of Injections] Corrections and rephrasings
Some corrections and rephrasings concerning the documentation.
1 parent b29856d commit 9654bed

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

service_container/injection_types.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Types of Injection
22
==================
33

4-
Making a class's dependencies explicit and requiring that they be injected
4+
Making a class's dependencies explicit and requiring that they must injected
55
into it is a good way of making a class more reusable, testable and decoupled
6-
from others.
6+
from the others.
77

88
There are several ways that the dependencies can be injected. Each injection
99
point has advantages and disadvantages to consider, as well as different
10-
ways of working with them when using the service container.
10+
ways of working with when using the service container.
1111

1212
Constructor Injection
1313
---------------------
@@ -81,17 +81,17 @@ service container configuration:
8181
Type hinting the injected object means that you can be sure that a suitable
8282
dependency has been injected. By type-hinting, you'll get a clear error
8383
immediately if an unsuitable dependency is injected. By type hinting
84-
using an interface rather than a class you can make the choice of dependency
84+
using an interface rather than a class you can make the choice of the dependency
8585
more flexible. And assuming you only use methods defined in the interface,
8686
you can gain that flexibility and still safely use the object.
8787

8888
There are several advantages to using constructor injection:
8989

9090
* If the dependency is a requirement and the class cannot work without it
91-
then injecting it via the constructor ensures it is present when the class
91+
then injecting it via the constructor ensures it is present especially when the class
9292
is used as the class cannot be constructed without it.
9393

94-
* The constructor is only ever called once when the object is created, so
94+
* The constructor is only called once when the object is created, so
9595
you can be sure that the dependency will not change during the object's
9696
lifetime.
9797

@@ -190,7 +190,7 @@ so, here's the advantages of immutable-setters:
190190
* Immutable setters works with optional dependencies, this way, if you don't need
191191
a dependency, the setter doesn't need to be called.
192192

193-
* Like the constructor injection, using immutable setters force the dependency to stay
193+
* Like the constructor injection, using immutable setters forces the dependency to stay
194194
the same during the lifetime of a service.
195195

196196
* This type of injection works well with traits as the service can be composed,
@@ -362,7 +362,7 @@ Another possibility is setting public fields of the class directly::
362362
->property('mailer', service('mailer'));
363363
};
364364
365-
There are mainly only disadvantages to using property injection, it is similar
365+
There are mainly only disadvantages to using property injection. It is similar
366366
to setter injection but with this additional important problem:
367367

368368
* You cannot control when the dependency is set at all, it can be changed

0 commit comments

Comments
 (0)