-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Service defaults not working for factories #22143
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
Comments
As a sidenote: shouldn't we completely be disallowing creation of a service called |
The whole As of 4.0 this could be possible, and with I like your usecase.. i would have tried exactly that. |
…precation notice (nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Enhance DX by throwing instead of triggering a deprecation notice | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes - at the config file level, for edge cases | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22143 | License | MIT | Doc PR | - Looking at the linked issue, I'm reconsidering our decision to trigger a deprecation notice when one uses `_instanceof` or `_defaults` as a service name. While on the BC side, this is strict - on the DX side, it looks like this opens a trap where people fill fall into. The same occurs to me with named args: instead of silently accepting invalid args as was the case before, let's throw to help DX when people do mistakes. Last change in this PR: the complex logic required to force strings to be given as `$id` args into `Reference` or `Alias` makes no sense to me, especially considering that a `string` type hint on PHP7 will *do* a string cast. Commits ------- b07da3d [DI] Enhance DX by throwing instead of triggering a deprecation notice
Given the new features with anonymous services and service defaults, I was assuming the following syntax would work:
This errors with: "Please add the class to service "_defaults" even if it is constructed by a factory since we might need to add method calls based on compile-time checks."
Changing the defaults to:
Appears to work at first, but doesn't, as this actually causes a service called
_defaults
to be created, and the other services in the file to ignore the defaults altogether.The text was updated successfully, but these errors were encountered: