Skip to content

Commit b373504

Browse files
committed
symfony httplug adapter needs php-http httplug to be installed
if we don't check for the httplug client interface, we trigger a warning: https://github.com/symfony/http-client/blob/290eb481973b4984eb59377585f6afbc65a0f645/HttplugClient.php#L44
1 parent 6a53322 commit b373504

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Psr18ClientDiscovery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function find()
2424
try {
2525
$client = static::findOneByType(ClientInterface::class);
2626
} catch (DiscoveryFailedException $e) {
27-
throw new \Http\Discovery\Exception\NotFoundException('No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example: "php-http/guzzle6-adapter".', 0, $e);
27+
throw new \Http\Discovery\Exception\NotFoundException('No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example: "php-http/guzzle7-adapter".', 0, $e);
2828
}
2929

3030
return static::instantiateClass($client);

src/Strategy/CommonClassesStrategy.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Http\Client\HttpAsyncClient;
1818
use Http\Client\HttpClient;
1919
use Http\Client\Socket\Client as Socket;
20+
use Http\Discovery\ClassDiscovery;
2021
use Http\Discovery\Exception\NotFoundException;
2122
use Http\Discovery\MessageFactoryDiscovery;
2223
use Http\Discovery\Psr17FactoryDiscovery;
@@ -101,7 +102,7 @@ final class CommonClassesStrategy implements DiscoveryStrategy
101102
Psr18Client::class => [
102103
[
103104
'class' => [self::class, 'symfonyPsr18Instantiate'],
104-
'condition' => [SymfonyPsr18::class, Psr17RequestFactory::class],
105+
'condition' => [HttpClient::class, SymfonyPsr18::class, Psr17RequestFactory::class],
105106
],
106107
[
107108
'class' => GuzzleHttp::class,
@@ -136,8 +137,11 @@ private static function getPsr18Candidates()
136137

137138
// HTTPlug 2.0 clients implements PSR18Client too.
138139
foreach (self::$classes[HttpClient::class] as $c) {
140+
if (!is_string($c['class'])) {
141+
continue;
142+
}
139143
try {
140-
if (is_subclass_of($c['class'], Psr18Client::class)) {
144+
if (ClassDiscovery::safeClassExists($c['class']) && is_subclass_of($c['class'], Psr18Client::class)) {
141145
$candidates[] = $c;
142146
}
143147
} catch (\Throwable $e) {

0 commit comments

Comments
 (0)