@@ -98,7 +98,7 @@ final class CommonClassesStrategy implements DiscoveryStrategy
98
98
],
99
99
[
100
100
'class ' => GuzzleHttp::class,
101
- 'condition ' => GuzzleHttp ::class,
101
+ 'condition ' => [ self ::class, ' isGuzzleImplementingPsr18 ' ] ,
102
102
],
103
103
[
104
104
'class ' => [self ::class, 'buzzInstantiate ' ],
@@ -125,18 +125,7 @@ public static function getCandidates($type)
125
125
*/
126
126
private static function getPsr18Candidates ()
127
127
{
128
- $ candidates = [];
129
-
130
- // Guzzle 6 does not implement the PSR-18 client interface, but Guzzle 7 does.
131
- foreach (self ::$ classes [Psr18Client::class] ?? [] as $ c ) {
132
- if (GuzzleHttp::class === $ c ['class ' ]) {
133
- if (defined ('GuzzleHttp\ClientInterface::MAJOR_VERSION ' )) {
134
- $ candidates [] = $ c ;
135
- }
136
- } else {
137
- $ candidates [] = $ c ;
138
- }
139
- }
128
+ $ candidates = self ::$ classes [Psr18Client::class];
140
129
141
130
// HTTPlug 2.0 clients implements PSR18Client too.
142
131
foreach (self ::$ classes [HttpClient::class] as $ c ) {
@@ -162,6 +151,11 @@ public static function symfonyPsr18Instantiate()
162
151
return new SymfonyPsr18 (null , Psr17FactoryDiscovery::findResponseFactory (), Psr17FactoryDiscovery::findStreamFactory ());
163
152
}
164
153
154
+ public static function isGuzzleImplementingPsr18 ()
155
+ {
156
+ return defined ('GuzzleHttp\ClientInterface::MAJOR_VERSION ' );
157
+ }
158
+
165
159
/**
166
160
* Can be used as a condition.
167
161
*
0 commit comments