-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Synthetic service cannot be define if binds are present #32874
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
What is the real name for the service that you used? So far it seems to me that you just forgot to configure its class. |
I do not have to declare my service class if I follow the documentation for synthetic services. See https://symfony.com/doc/current/service_container/synthetic_services.html : # config/services.yaml
services:
# synthetic services don't specify a class
app.synthetic_service:
synthetic: true If I remove the bind declaration, everything works fine. Another exemple of synthetic service is the <service id="kernel" synthetic="true" public="true" /> |
if I add: if (null !== $class && !$definition->isSynthetic()) { around try on line 145 in symfony/dependency-injection/Compiler/AbstractRecursivePass.php and give $r variable default null value, this doesn't happen anymore. I did add that null !== $class check but in my limited synthetic service knowledge, I don't actually see point of that check. Maybe someone more experienced with this can tell if it's a needed check to have here? Than maybe there's no need to do if around try and just add: if ($definition->isSynthetic()) {
return null;
} at the top of the function |
@k0d3r1s looks like this could be the fix. Could you please send a PR on branch 3.4, with a test case? |
@nicolas-grekas can you point me towards an example on how to define that default bind inside a test case? Edit: Nevermind :) |
…synthetic (k0d3r1s) This PR was squashed before being merged into the 3.4 branch (closes #33625). Discussion ---------- [DependencyInjection] Fix wrong exception when service is synthetic | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #32874 | License | MIT This fixes wrongfully thrown exception when service is defined as synthetic and some arguments are binded in _defaults Commits ------- 152dec9 [DependencyInjection] Fix wrong exception when service is synthetic
Symfony version(s) affected: tested with 3.4 and 4.3
Description
If I define a synthetic service in my service.yaml config file where binds are already defined, I get the error
How to reproduce
config/services.yaml
This error is a little more understandable than the first one, but I have to try finding the minimal failing exemple to get this error
This error is way worse to debug the real problem
The text was updated successfully, but these errors were encountered: