Skip to content

Commit aa28926

Browse files
committed
minor #18756 Remove paragraph about the impossibility to typehint a property (l-vo)
This PR was merged into the 5.4 branch. Discussion ---------- Remove paragraph about the impossibility to typehint a property <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 974914f Remove paragraph about the impossibility to typehint a property
2 parents 575e55e + 974914f commit aa28926

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

service_container/injection_types.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,11 @@ Another possibility is setting public fields of the class directly::
364364
};
365365
366366
There are mainly only disadvantages to using property injection, it is similar
367-
to setter injection but with these additional important problems:
367+
to setter injection but with this additional important problem:
368368

369369
* You cannot control when the dependency is set at all, it can be changed
370370
at any point in the object's lifetime.
371371

372-
* You cannot use type hinting so you cannot be sure what dependency is injected
373-
except by writing into the class code to explicitly test the class instance
374-
before using it.
375-
376372
But, it is useful to know that this can be done with the service container,
377373
especially if you are working with code that is out of your control, such
378374
as in a third party library, which uses public properties for its dependencies.

0 commit comments

Comments
 (0)