-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Q | A |
---|---|
Bug? | no |
New Feature? | yes |
Version | 1.14.0 |
Actual Behavior
We are heavily using Symfony's auto wire functionality. Sometimes, developer inject HttpClient in the constructor without actually specifying the exact httplug.client.name
. No error is thrown, and HTTPlug just picks the httplug.client.default
service (or the first client it can find)
Expected Behavior
Don't register a default Http\Client\HttpClient
service and Symfony will automatically warn the developer that multiple services of Http\Client\HttpClient
exist. Developer is then notified about this and will think :)
Possible Solutions
I really propose to get rid of this behaviour in the next major version of this bundle.
Related code
HttplugBundle/DependencyInjection/HttplugExtension.php
Lines 115 to 123 in 8b7cb00
// If we do not have a client named 'default' | |
if (!array_key_exists('default', $config['clients'])) { | |
$serviceId = 'httplug.client.'.$first; | |
// Alias the first client to httplug.client.default | |
$container->setAlias('httplug.client.default', $serviceId); | |
$default = $first; | |
} else { | |
$default = 'default'; | |
} |
HttplugBundle/Resources/config/services.xml
Lines 44 to 46 in a6466b4
<service id="httplug.client.default" class="Http\Client\HttpClient"> | |
<factory class="Http\Discovery\HttpClientDiscovery" method="find" /> | |
</service> |