Skip to content

Commit 9ed2735

Browse files
committed
Fixing test with Symfony Http Client
1 parent cccafdd commit 9ed2735

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"symfony/finder": "~4.0",
2727
"nyholm/psr7": "^1.5",
2828
"php-http/mock-client": "^1.5",
29-
"symfony/http-client": "^5.0|^6.0"
29+
"symfony/http-client": "^5.0|^6.0",
30+
"php-http/message-factory": "^1.1"
3031
},
3132
"autoload": {
3233
"psr-4": {

src/ClientBuilder.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Elastic\Elasticsearch\Transport\Adapter\AdapterInterface;
2222
use Elastic\Elasticsearch\Transport\Adapter\AdapterOptions;
2323
use Elastic\Elasticsearch\Transport\RequestOptions;
24+
use Elastic\Transport\Exception\NoAsyncClientException;
2425
use Elastic\Transport\NodePool\NodePoolInterface;
2526
use Elastic\Transport\Transport;
2627
use Elastic\Transport\TransportBuilder;
@@ -411,8 +412,12 @@ protected function isSymfonyHttpClient(Transport $transport): bool
411412
if (false !== strpos(get_class($transport->getClient()), 'Symfony\Component\HttpClient')) {
412413
return true;
413414
}
414-
if (false !== strpos(get_class($transport->getAsyncClient()), 'Symfony\Component\HttpClient')) {
415-
return true;
415+
try {
416+
if (false !== strpos(get_class($transport->getAsyncClient()), 'Symfony\Component\HttpClient')) {
417+
return true;
418+
}
419+
} catch (NoAsyncClientException $e) {
420+
return false;
416421
}
417422
return false;
418423
}

0 commit comments

Comments
 (0)