Skip to content

Commit

Permalink
Check if SymfonyHttplug actually implements HttpClient (#253)
Browse files Browse the repository at this point in the history
* Check if SymfonyHttplug actually implements HttpClient

* Use is_subclass_of

Co-authored-by: Nicolas Grekas <[email protected]>

---------

Co-authored-by: Nicolas Grekas <[email protected]>
  • Loading branch information
arokettu and nicolas-grekas authored Nov 30, 2023
1 parent 57f3de0 commit bbb2b52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Strategy/CommonClassesStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit bbb2b52

Please sign in to comment.