-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add a mechanism to deprecate public services to private #36470
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
Merged
nicolas-grekas
merged 1 commit into
symfony:master
from
fancyweb:di-deprecate-public-service
May 4, 2020
Merged
[DependencyInjection] Add a mechanism to deprecate public services to private #36470
nicolas-grekas
merged 1 commit into
symfony:master
from
fancyweb:di-deprecate-public-service
May 4, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e080ce2
to
51e8723
Compare
fancyweb
commented
Apr 16, 2020
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Show resolved
Hide resolved
51e8723
to
e1b3324
Compare
e1b3324
to
0df92cb
Compare
yceruto
approved these changes
Apr 30, 2020
stof
requested changes
Apr 30, 2020
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Outdated
Show resolved
Hide resolved
0df92cb
to
ff01714
Compare
stof
approved these changes
May 4, 2020
There was a problem hiding this 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.
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Outdated
Show resolved
Hide resolved
ff01714
to
0a8853b
Compare
0a8853b
to
3e80e46
Compare
nicolas-grekas
approved these changes
May 4, 2020
Thank you @fancyweb. |
Merged
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 afterResolveReferencesToAliasesPass
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 !