Description
Description
If I create an http client:
http_client:
scoped_clients:
githubApi:
scope: 'https://api\.github\.com'
headers:
Accept: 'application/vnd.github.v3+json'
And I want to inject it into my service, I can do:
public function __construct(
#[Target('githubApi2')]
private HttpClientInterface $something,
) {
}
But oups, I made a typo. I wrote githubApi2
instead of githubApi
. But for Symfony it's OK. Instead it injects a new "blank" HttpClient (with no sane default configuration - no timeout for example).
IMHO, if one want to inject a specific target, the target must be validated. And if the target does not exist, because another developer renamed it, you want an exception. for this.
see this comments for a previous discussion.
But IMHO, if the naming is not exactly the same as the autowire alias, it's fine to not raise an exception. But in this very use case, you really want this alias. Not another one.
So I would expect an exception.
WDYT?
Example
No response