diff --git a/src/Psr18ClientDiscovery.php b/src/Psr18ClientDiscovery.php index 7fcdb17..dfd2dd1 100644 --- a/src/Psr18ClientDiscovery.php +++ b/src/Psr18ClientDiscovery.php @@ -24,7 +24,7 @@ public static function find() try { $client = static::findOneByType(ClientInterface::class); } catch (DiscoveryFailedException $e) { - 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); + 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); } return static::instantiateClass($client); diff --git a/src/Strategy/CommonClassesStrategy.php b/src/Strategy/CommonClassesStrategy.php index b950e96..8bddbe8 100644 --- a/src/Strategy/CommonClassesStrategy.php +++ b/src/Strategy/CommonClassesStrategy.php @@ -17,6 +17,7 @@ use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Http\Client\Socket\Client as Socket; +use Http\Discovery\ClassDiscovery; use Http\Discovery\Exception\NotFoundException; use Http\Discovery\MessageFactoryDiscovery; use Http\Discovery\Psr17FactoryDiscovery; @@ -136,8 +137,11 @@ private static function getPsr18Candidates() // HTTPlug 2.0 clients implements PSR18Client too. foreach (self::$classes[HttpClient::class] as $c) { + if (!is_string($c['class'])) { + continue; + } try { - if (is_subclass_of($c['class'], Psr18Client::class)) { + if (ClassDiscovery::safeClassExists($c['class']) && is_subclass_of($c['class'], Psr18Client::class)) { $candidates[] = $c; } } catch (\Throwable $e) {