From bbb2b52b984e63c5103f90ac24c15ab1593c697f Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Thu, 30 Nov 2023 18:36:57 +0200 Subject: [PATCH] Check if SymfonyHttplug actually implements HttpClient (#253) * Check if SymfonyHttplug actually implements HttpClient * Use is_subclass_of Co-authored-by: Nicolas Grekas --------- Co-authored-by: Nicolas Grekas --- src/Strategy/CommonClassesStrategy.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Strategy/CommonClassesStrategy.php b/src/Strategy/CommonClassesStrategy.php index ae0b0d8..0fa4240 100644 --- a/src/Strategy/CommonClassesStrategy.php +++ b/src/Strategy/CommonClassesStrategy.php @@ -78,7 +78,7 @@ final class CommonClassesStrategy implements DiscoveryStrategy ['class' => React::class, 'condition' => React::class], ], HttpClient::class => [ - ['class' => SymfonyHttplug::class, 'condition' => [SymfonyHttplug::class, [self::class, 'isPsr17FactoryInstalled']]], + ['class' => SymfonyHttplug::class, 'condition' => [SymfonyHttplug::class, [self::class, 'isPsr17FactoryInstalled'], [self::class, 'isSymfonyImplementingHttpClient']]], ['class' => Guzzle7::class, 'condition' => Guzzle7::class], ['class' => Guzzle6::class, 'condition' => Guzzle6::class], ['class' => Guzzle5::class, 'condition' => Guzzle5::class], @@ -158,6 +158,11 @@ public static function isGuzzleImplementingPsr18() return defined('GuzzleHttp\ClientInterface::MAJOR_VERSION'); } + public static function isSymfonyImplementingHttpClient() + { + return is_subclass_of(SymfonyHttplug::class, HttpClient::class); + } + /** * Can be used as a condition. *