Skip to content
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

[DependencyInjection] Add a mechanism to deprecate public services to private #36470

Merged

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Apr 16, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

This PR adds a mechanism to easily deprecate public services to private, ie a public service will be private in a next version.

It works with a tag and a compiler pass. The pass creates a deprecated public alias of the public service.

It is ran "after removing" because we want to trigger only on direct accesses to the public service ($container->get()): if the public service was removed, we don't need to do anything because there is no impact.

All references to the public service are kept because the deprecated public alias is created after ResolveReferencesToAliasesPass so only direct access actually uses the deprecated alias.
All references to the public service are altered to a direct reference to the alias target service so that they don't trigger the alias deprecation.

Thanks to @nicolas-grekas for sharing some ideas and helping me !

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things and GTM.

@fancyweb fancyweb force-pushed the di-deprecate-public-service branch from ff01714 to 0a8853b Compare May 4, 2020 13:37
@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit a910192 into symfony:master May 4, 2020
@fancyweb fancyweb deleted the di-deprecate-public-service branch May 4, 2020 13:43
@fabpot fabpot mentioned this pull request May 5, 2020
nicolas-grekas added a commit that referenced this pull request Dec 8, 2020
… private container to remove false-positive deprecations (nicolas-grekas)

This PR was merged into the 5.1 branch.

Discussion
----------

[FrameworkBundle] acces public-deprecated services via the private container to remove false-positive deprecations

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Something we missed in #36470 apparently.

Commits
-------

d502ba9 [FrameworkBundle] acces public-deprecated services via the private container to remove false-positive deprecations
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.

None yet

5 participants