Skip to content

Commit cf1bf4d

Browse files
committed
Fix #902 Incorrect return typehint when using async requests
1 parent 9176508 commit cf1bf4d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Elasticsearch/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1550,9 +1550,9 @@ private function verifyNotNullOrEmpty(string $name, $var)
15501550
}
15511551

15521552
/**
1553-
* @throws \Exception
1553+
* @return callable|array
15541554
*/
1555-
private function performRequest(AbstractEndpoint $endpoint): array
1555+
private function performRequest(AbstractEndpoint $endpoint)
15561556
{
15571557
$promise = $this->transport->performRequest(
15581558
$endpoint->getMethod(),

tests/Elasticsearch/Tests/ClientTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Elasticsearch\Client;
99
use Elasticsearch\ClientBuilder;
1010
use Elasticsearch\Common\Exceptions\MaxRetriesException;
11+
use GuzzleHttp\Ring\Client\MockHandler;
12+
use GuzzleHttp\Ring\Future\FutureArray;
1113
use Mockery as m;
1214

1315
/**
@@ -445,4 +447,28 @@ public function testExtendedHosts()
445447
$this->assertSame("http", $host->getTransportSchema());
446448
$this->assertSame("user:abc#$@?%!abc", $host->getUserPass());
447449
}
450+
451+
public function testClientLazy()
452+
{
453+
$handler = new MockHandler([
454+
'status' => 200,
455+
'transfer_stats' => [
456+
'total_time' => 100
457+
],
458+
'body' => '{test}',
459+
'effective_url' => 'localhost'
460+
]);
461+
$builder = ClientBuilder::create();
462+
$builder->setHosts(['somehost']);
463+
$builder->setHandler($handler);
464+
$client = $builder->build();
465+
466+
$params = [
467+
'client' => [
468+
'future' => 'lazy',
469+
]
470+
];
471+
$result = $client->info($params);
472+
$this->assertInstanceOf(FutureArray::class, $result);
473+
}
448474
}

0 commit comments

Comments
 (0)