From 9dd5111ab2d1ea67785e2cdea1fb9ed95d3882d6 Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Mon, 17 Feb 2025 18:23:27 +0100 Subject: [PATCH] Fix #297 Signed-off-by: Romain Ruaud --- src/OpenSearch/Client.php | 4 ++-- src/OpenSearch/HttpTransport.php | 2 +- src/OpenSearch/LegacyTransportWrapper.php | 11 ++++------- src/OpenSearch/TransportInterface.php | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index 43f4f1efb..889d6fba8 100644 --- a/src/OpenSearch/Client.php +++ b/src/OpenSearch/Client.php @@ -2155,7 +2155,7 @@ public function request( string $method, string $uri, array $attributes = [] - ): array|string|null { + ): \Traversable|array|string|null { $params = $attributes['params'] ?? []; $body = $attributes['body'] ?? null; $options = $attributes['options'] ?? []; @@ -2169,7 +2169,7 @@ public function request( * @throws \Psr\Http\Client\ClientExceptionInterface * @throws \OpenSearch\Exception\HttpExceptionInterface */ - private function performRequest(AbstractEndpoint $endpoint): array|string|null + private function performRequest(AbstractEndpoint $endpoint): \Traversable|array|string|null { return $this->httpTransport->sendRequest( $endpoint->getMethod(), diff --git a/src/OpenSearch/HttpTransport.php b/src/OpenSearch/HttpTransport.php index 676fce4fd..1802b0801 100644 --- a/src/OpenSearch/HttpTransport.php +++ b/src/OpenSearch/HttpTransport.php @@ -36,7 +36,7 @@ public function sendRequest( array $params = [], mixed $body = null, array $headers = [], - ): array|string|null { + ): \Traversable|array|string|null { $request = $this->createRequest($method, $uri, $params, $body, $headers); $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); diff --git a/src/OpenSearch/LegacyTransportWrapper.php b/src/OpenSearch/LegacyTransportWrapper.php index 7335a4d8f..73167dcab 100644 --- a/src/OpenSearch/LegacyTransportWrapper.php +++ b/src/OpenSearch/LegacyTransportWrapper.php @@ -28,13 +28,10 @@ public function sendRequest( array $params = [], mixed $body = null, array $headers = [], - ): array|string|null { - $promise = $this->transport->performRequest($method, $uri, $params, $body); - $futureArray = $this->transport->resultOrFuture($promise); - if ($futureArray instanceof FutureArrayInterface) { - return $futureArray->wait(); - } - return $futureArray; + ): \Traversable|array|string|null { + $promise = $this->transport->performRequest($method, $uri, $params, $body, $headers); + + return $this->transport->resultOrFuture($promise, $headers); } } diff --git a/src/OpenSearch/TransportInterface.php b/src/OpenSearch/TransportInterface.php index c2f432d30..adc169657 100644 --- a/src/OpenSearch/TransportInterface.php +++ b/src/OpenSearch/TransportInterface.php @@ -23,6 +23,6 @@ public function sendRequest( array $params = [], string|array|null $body = null, array $headers = [], - ): array|string|null; + ): \Traversable|array|string|null; }