Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DI] Deprecate (un)setting pre-defined services#21533
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| unset($this->privates[$id]); | ||
| }else { | ||
| @trigger_error(sprintf('Setting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. A new public service will be created instead.',$id),E_USER_DEPRECATED); | ||
| @trigger_error(sprintf('Setting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.',$id),E_USER_DEPRECATED); |
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.
Removing this tail:
A new public service will be created instead.
it's not obvious to me that this will be the behavior we should implement in 4.0 :)
bcb4b45 to90eb386Comparero0NL commentedFeb 5, 2017
Shouldnt we deprecate the |
nicolas-grekas commentedFeb 5, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That's the point of this PR:#19668 is deprecating much more than technically required to enhance the dumped containers in 4.0. In fact, even if I listen to the "best practice" arguments in#19668, we know that forbidding altogether not-best-practices can break legitimate edge-case use cases (remember the deprecation of "get" in non dumped containers that we reverted). Thus, I'm not sure at all we should merge#19668 - but I'm sure we should merge this one, because it will make SF4 betterat the technical level. |
90eb386 tofdb2140Comparestof commentedFeb 7, 2017
👍 |
fabpot commentedFeb 12, 2017
Thank you@nicolas-grekas. |
This PR was merged into the 3.3-dev branch.Discussion----------[DI] Deprecate (un)setting pre-defined services| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | yes| Tests pass? | no| Fixed tickets |#19192| License | MIT| Doc PR | -This PR is the subset of#19668 thatfixes#19192: it deprecates (un)setting pre-defined services.This opens the path to some optimizations in the dumped container in 4.0.Commits-------fdb2140 [DI] Deprecate (un)setting pre-defined services
xkobal commentedMay 17, 2017
I am testing SF 3.3BETA1 and I've got a trouble with that Pull Request:
When I try to replace Service with
What is my solution for this kind of functional tests ? Thanks for the answer. |
chalasr commentedMay 17, 2017
By loading dedicated config files in your tests? Seehttps://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.phphttps://github.com/symfony/symfony/tree/master/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear for inspiration |
stof commentedMay 17, 2017
@xkobal injecting a PHPUnit mock to replace a service instance is a very fragile setup: if any other services depending on this service got instantiated already before your |
OwlyCode commentedMay 17, 2017
The config approach is indeed much stronger. I also used to mock services with the |
xkobal commentedMay 17, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm agree with you on that point, and I'll change my tests, but, thats a way to test services, very very used on a lot of project ! It'll be a painful point for a lot of projects to upgrade to SF 3.3 Thanks for your answers. |
nicolas-grekas commentedMay 17, 2017
Note that you don'tneed to fix the deprecations when moving to 3.3. |
xkobal commentedMay 17, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I never upgrade a project letting some deprecations, our CI is failing on phpunit tests when there are some deprecations, but that's our choice, others can ignore them. |
stof commentedMay 17, 2017
Well, you can mark these tests as |
…rvices (ro0NL)This PR was merged into the 4.0-dev branch.Discussion----------[DI] Removed deprecated setting private/pre-defined services| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | yes| Deprecations? | no| Tests pass? | yes| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->See#21533,#19708 and#19146@nicolas-grekas privates should be excluded from `getServiceIds` right? i also wondered.. did we forget to deprecate checking privates with `initialized()`?Commits-------9f96952 [DI] Removed deprecated setting private/pre-defined services
scott-r-lindsey commentedAug 2, 2017
This is going to be difficult for my use case -- I replace guzzle clients with guzzle mock handlers loaded with responses (per test), and I validate both the response and the request made. @chalasr "use config files" assumes that a service can be reconfigured (or replaced) by way of configuration alone, and also that tests can all use the same configuration. @stof We're talking about testing here -- tests are supposed to be fragile. This isn't looking good. Am I going to have to forgo booting a kernel and just build my services by hand before testing them? Or, perhaps, I create intermediary objects that can know how to replace themselves on demand? Either way, I have to take over work that I could previously count on my framework to do. |
nicolas-grekas commentedAug 2, 2017
Please open an issue to discuss this. |
scott-r-lindsey commentedAug 2, 2017
I'm adding a comment to#23311. |
chalasr commentedAug 2, 2017
You should open a new issue really. Comments on closed tickets aren't tracked. |
Uh oh!
There was an error while loading.Please reload this page.
This PR is the subset of#19668 thatfixes#19192: it deprecates (un)setting pre-defined services.
This opens the path to some optimizations in the dumped container in 4.0.