Skip to content

[DependencyInjection] Do not trigger deprecation when injecting private services #19682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Aug 20, 2016

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19680
License MIT
Doc PR -

The deprecation notice should not be triggered when a private service is injected. This PR adds a virtual third argument to get() to disable triggering the deprecation notice when getting from the dumped container.

@wouterj wouterj changed the title Issue 19680/injected private services [DependencyInjection] Do not trigger deprecation when injecting private services Aug 20, 2016
@ro0NL
Copy link
Contributor

ro0NL commented Aug 20, 2016

I prefer a fix that doesnt allow accessing prrivate services via public get. This is a workaround :)

We deprecate get('private'), but add get('private', $x, $giveMePrivate).

@nicolas-grekas
Copy link
Member

See #19708

@wouterj wouterj closed this Aug 22, 2016
@wouterj wouterj deleted the issue-19680/injected-private-services branch August 22, 2016 17:49
fabpot added a commit that referenced this pull request Sep 1, 2016
…ces internally (nicolas-grekas)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[DI] Dont use Container::get() when fetching private services internally

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19683, #19682, #19680
| License       | MIT

As spotted by @wouterj, we forgot to remove the deprecation notice when doing internal calls to get private services.

Yet, we don't need to get through this `get()` method, because we can already resolve many things at compile time for private services. This will provide another small performance optim, and fix the issue.

Commits
-------

a9c79fb [DI] Dont use Container::get() when fetching private services internally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants