Skip to content

Commit e89c695

Browse files
committed
Make sure we support any psr-18 client
1 parent 599e7d4 commit e89c695

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Collector/PluginClientFactory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Http\Client\Common\PluginClient;
77
use Http\Client\HttpAsyncClient;
88
use Http\Client\HttpClient;
9+
use Http\HttplugBundle\Tests\Unit\Collector\ClientInterface;
910
use Symfony\Component\Stopwatch\Stopwatch;
1011

1112
/**
@@ -46,9 +47,9 @@ public function __construct(Collector $collector, Formatter $formatter, Stopwatc
4647
}
4748

4849
/**
49-
* @param HttpClient|HttpAsyncClient $client
50-
* @param Plugin[] $plugins
51-
* @param array $options {
50+
* @param HttpClient|ClientInterface|HttpAsyncClient $client
51+
* @param Plugin[] $plugins
52+
* @param array $options {
5253
*
5354
* @var string $client_name to give client a name which may be used when displaying client information like in
5455
* the HTTPlugBundle profiler.

Collector/ProfileClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Http\Client\Exception\HttpException;
88
use Http\Client\HttpAsyncClient;
99
use Http\Client\HttpClient;
10+
use Http\HttplugBundle\Tests\Unit\Collector\ClientInterface;
1011
use Psr\Http\Message\RequestInterface;
1112
use Psr\Http\Message\ResponseInterface;
1213
use Symfony\Component\Stopwatch\Stopwatch;
@@ -58,7 +59,7 @@ class ProfileClient implements HttpClient, HttpAsyncClient
5859
*/
5960
public function __construct($client, Collector $collector, Formatter $formatter, Stopwatch $stopwatch)
6061
{
61-
if (!($client instanceof HttpClient && $client instanceof HttpAsyncClient)) {
62+
if (!(($client instanceof ClientInterface || $client instanceof HttpClient) && $client instanceof HttpAsyncClient)) {
6263
$client = new FlexibleHttpClient($client);
6364
}
6465

Collector/ProfileClientFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Http\Client\HttpAsyncClient;
77
use Http\Client\HttpClient;
88
use Http\HttplugBundle\ClientFactory\ClientFactory;
9+
use Psr\Http\Client\ClientInterface;
910
use Symfony\Component\Stopwatch\Stopwatch;
1011

1112
/**
@@ -61,7 +62,7 @@ public function createClient(array $config = [])
6162
{
6263
$client = is_callable($this->factory) ? call_user_func($this->factory, $config) : $this->factory->createClient($config);
6364

64-
if (!($client instanceof HttpClient && $client instanceof HttpAsyncClient)) {
65+
if (!(($client instanceof HttpClient || $client instanceof ClientInterface) && $client instanceof HttpAsyncClient)) {
6566
$client = new FlexibleHttpClient($client);
6667
}
6768

0 commit comments

Comments
 (0)