backport service factory improvements
minor #4518 [Components][DependencyInjection] backport service factory improvements (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Components][DependencyInjection] backport service factory improvements

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | all
| Fixed tickets |

Commits
-------

c787637 backport service factory improvements