Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DX][DependencyInjection] Suggest to write an implementation if the interface cannot be autowired#25547
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
[DX][DependencyInjection] Suggest to write an implementation if the interface cannot be autowired#25547
Uh oh!
There was an error while loading.Please reload this page.
Conversation
50da469 tocb333cdComparenicolas-grekas commentedDec 19, 2017
Isn't this just stating the obvious? |
sroze commentedDec 19, 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.
@nicolas-grekas well, I'd say so as well, but I just saw a developer having this issue; and such message would have helped him. It doesn't cost us anything to phrase it a bit differently and benefits is it helps some :) |
Simperfit commentedDec 20, 2017
I agree with@sroze people could have this kinds of errors, and doing this help them to develop. |
weaverryan commentedDec 20, 2017 • edited by nicolas-grekas
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by nicolas-grekas
Uh oh!
There was an error while loading.Please reload this page.
I like this step. In 3.4, we already create interface aliases if you have a service that implements that interface. So, indeed, it seems likemost of the time, the solutionwould indeed be to simply create a class that implements this interface (then the interface alias would be created and it would autowire). So, talking this through, yea, I think that this recommendation isalways correct. So why not? |
| $message =sprintf('references %s "%s" but %s.%s',$r->isInterface() ?'interface' :'class',$type,$message,$this->createTypeAlternatives($reference)); | ||
| if ($r->isInterface()) { | ||
| $message .=' Did you write an implementation of this interface?'; |
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.
What about:
Did you create a class that implements this interface?
Or:
You may need to create a class that implements this interface.
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.
I like "Did you create a class that implements this interface?"
stof commentedDec 20, 2017
not true, as the alias is created automatically only if the implementationand the interface are both discovered by the PSR-4 discovery. A third-party interface will not be discovered in |
cb333cd to961e3e7Comparesroze commentedDec 24, 2017
Updated the message based on@weaverryan's 1st suggestion 👍 |
…on if the interface cannot be autowired (sroze)This PR was merged into the 3.4 branch.Discussion----------[DX][DependencyInjection] Suggest to write an implementation if the interface cannot be autowired| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | ø| License | MIT| Doc PR | øThis would add a hint for the developers when the interface cannot be wired. This suggests creating the implementation of the interface.**Note:** this is 3.4 because I believe DX should be treated as bugs.**Note 2:** fabbot issue is false positiveCommits-------961e3e7 Suggest to write an implementation if the interface cannot be autowired
Uh oh!
There was an error while loading.Please reload this page.
This would add a hint for the developers when the interface cannot be wired. This suggests creating the implementation of the interface.
Note: this is 3.4 because I believe DX should be treated as bugs.
Note 2: fabbot issue is false positive