diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index 43f4f1ef..963a9270 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'] ?? []; diff --git a/src/OpenSearch/HttpTransport.php b/src/OpenSearch/HttpTransport.php index 676fce4f..1802b080 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 7335a4d8..73167dca 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 c2f432d3..adc16965 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; }