-
Notifications
You must be signed in to change notification settings - Fork 49
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
PSR-17 should be available to use Symfony's HttplugClient #150
Conversation
I can confirm that this change fixes #149 |
|
@@ -72,7 +73,7 @@ final class CommonClassesStrategy implements DiscoveryStrategy | |||
['class' => React::class, 'condition' => React::class], | |||
], | |||
HttpClient::class => [ | |||
['class' => SymfonyHttplug::class, 'condition' => SymfonyHttplug::class], | |||
['class' => SymfonyHttplug::class, 'condition' => [SymfonyHttplug::class, Psr17RequestFactory::class]], |
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.
Won't this possibly break applications using HttpClient 4.3 where this was not necessary?
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.
The HttplugClient
class that this is checking for doesn't exist in HttpClient 4.3 so it shouldn't be an issue.
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.
Awesome. Thank you
Ooops. I was too quick. It should be the message factory from HTTPlug. |
It looks like the fix was reverted by 4257709 Symfony 4.4 is still broken! |
did you try with discovery 1.7.2? we had to fix checks to also look at interfaces and not only classes. |
What's in this PR?
This is a bit of a stab in the dark, but I ran into the same problem in that issue and it seems like this PR should fix it.
Since #141 Symfony's
Symfony\Component\HttpClient\HttplugClient
is the first client class attempted when using auto-discovery, with its only condition being that that specific class is available (which is true if you havesymfony/http-client >=4.4
installed). However, if you don't have anything which satisfies the PSR-17 auto discovery installed, then auto-discovery as a whole is going to fail because the Symfony class can't be instantiated.This PR attempts to fix the issue by adding a condition on the PSR-17 interfaces being present as well. Looking at the Symfony app where I ran into the problem (Symfony 3.4 with the HttpClient component being pulled in as a transient dependency at 4.4), it seems like this would fix the problem because through that application's transient dependencies PSR-17 isn't installed so this condition should fail and it fall through to a working client (Guzzle in this application's case).
Checklist
To Do