diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c72471793..7a99329bc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Added support for PHP 8.2 [#2136](https://github.com/ruflin/Elastica/pull/2136) +* Added missing `@throws` annotations to Client::request and related methods [#2152](https://github.com/ruflin/Elastica/pull/2152) ### Changed * Updated `php-cs-fixer` to `3.13.2` [#2143](https://github.com/ruflin/Elastica/pull/2143) * Modernize code using `match` expression [#2141](https://github.com/ruflin/Elastica/pull/2141) diff --git a/src/Bulk.php b/src/Bulk.php index 3b202101cc..28ec464571 100644 --- a/src/Bulk.php +++ b/src/Bulk.php @@ -6,10 +6,12 @@ use Elastica\Bulk\Action\AbstractDocument as AbstractDocumentAction; use Elastica\Bulk\Response as BulkResponse; use Elastica\Bulk\ResponseSet; -use Elastica\Exception\Bulk\ResponseException; use Elastica\Exception\Bulk\ResponseException as BulkResponseException; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; use Elastica\Exception\RequestEntityTooLargeException; +use Elastica\Exception\ResponseException; use Elastica\Script\AbstractScript; class Bulk @@ -274,6 +276,13 @@ public function toArray(): array return $data; } + /** + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException + * @throws InvalidException + */ public function send(): ResponseSet { $response = $this->_client->request($this->getPath(), Request::POST, (string) $this, $this->_requestParams, Request::NDJSON_CONTENT_TYPE); @@ -282,7 +291,7 @@ public function send(): ResponseSet } /** - * @throws ResponseException + * @throws BulkResponseException * @throws InvalidException */ protected function _processResponse(Response $response): ResponseSet diff --git a/src/Client.php b/src/Client.php index a59b13bc43..aa34f1c355 100644 --- a/src/Client.php +++ b/src/Client.php @@ -4,6 +4,7 @@ use Elastica\Bulk\Action; use Elastica\Bulk\ResponseSet; +use Elastica\Exception\Bulk\ResponseException as BulkResponseException; use Elastica\Exception\ClientException; use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; @@ -86,6 +87,10 @@ public function __construct($config = [], ?callable $callback = null, ?LoggerInt /** * Get current version. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function getVersion(): string { @@ -203,7 +208,11 @@ public function removeHeader(string $header): self * * @param array|Document[] $docs Array of Elastica\Document * - * @throws InvalidException If docs is empty + * @throws InvalidException If docs is empty + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException */ public function updateDocuments(array $docs, array $requestParams = []): ResponseSet { @@ -232,7 +241,11 @@ public function updateDocuments(array $docs, array $requestParams = []): Respons * * @param array|Document[] $docs Array of Elastica\Document * - * @throws InvalidException If docs is empty + * @throws InvalidException If docs is empty + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException */ public function addDocuments(array $docs, array $requestParams = []): ResponseSet { @@ -260,6 +273,10 @@ public function addDocuments(array $docs, array $requestParams = []): ResponseSe * @param array $options array of query params to use for query. For possible options check es api * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function updateDocument($id, $data, $index, array $options = []): Response { @@ -321,6 +338,10 @@ public function updateDocument($id, $data, $index, array $options = []): Respons * @param array|Document[] $docs * * @throws InvalidException + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException */ public function deleteDocuments(array $docs, array $requestParams = []): ResponseSet { @@ -434,6 +455,10 @@ public function setConnections(array $connections) * @param bool|string $routing Optional routing key for all ids * * @throws InvalidException + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException */ public function deleteIds(array $ids, $index, $routing = false): ResponseSet { @@ -478,6 +503,9 @@ public function deleteIds(array $ids, $index, $routing = false): ResponseSet * * @throws ResponseException * @throws InvalidException + * @throws ClientException + * @throws ConnectionException + * @throws BulkResponseException */ public function bulk(array $params): ResponseSet { @@ -542,6 +570,10 @@ public function request(string $path, string $method = Request::GET, $data = [], /** * Makes calls to the elasticsearch server with usage official client Endpoint. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function requestEndpoint(AbstractEndpoint $endpoint): Response { @@ -559,6 +591,10 @@ public function requestEndpoint(AbstractEndpoint $endpoint): Response * @param array $args OPTIONAL Optional arguments * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function forcemergeAll($args = []): Response { @@ -572,6 +608,10 @@ public function forcemergeAll($args = []): Response * Closes the given PointInTime. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html#close-point-in-time-api + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function closePointInTime(string $pointInTimeId): Response { @@ -585,6 +625,10 @@ public function closePointInTime(string $pointInTimeId): Response * Refreshes all search indices. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function refreshAll(): Response { diff --git a/src/Cluster.php b/src/Cluster.php index 297da86bcb..d36cf147b4 100644 --- a/src/Cluster.php +++ b/src/Cluster.php @@ -4,6 +4,9 @@ use Elastica\Cluster\Health; use Elastica\Cluster\Settings; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\ResponseException; use Elasticsearch\Endpoints\Cluster\State; /** @@ -47,6 +50,10 @@ public function __construct(Client $client) /** * Refreshes all cluster information (state). + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function refresh(): void { diff --git a/src/Cluster/Health.php b/src/Cluster/Health.php index 69039ede25..244cf5fc7f 100644 --- a/src/Cluster/Health.php +++ b/src/Cluster/Health.php @@ -4,6 +4,9 @@ use Elastica\Client; use Elastica\Cluster\Health\Index; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\ResponseException; /** * Elastic cluster health. @@ -175,6 +178,10 @@ public function getIndices(): array /** * Retrieves the health data from the cluster. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ protected function _retrieveHealthData(): array { diff --git a/src/Index.php b/src/Index.php index be90077bdc..161507c17c 100644 --- a/src/Index.php +++ b/src/Index.php @@ -3,6 +3,9 @@ namespace Elastica; use Elastica\Bulk\ResponseSet; +use Elastica\Exception\Bulk\ResponseException as BulkResponseException; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; use Elastica\Exception\NotFoundException; use Elastica\Exception\ResponseException; @@ -111,6 +114,10 @@ public function setMapping(Mapping $mapping, array $query = []): Response /** * Gets all mappings for the current index. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function getMapping(): array { @@ -152,6 +159,12 @@ public function createDocument(string $id = '', $data = []) * @param Document[] $docs Array of Elastica\Document * @param array $options Array of query params to use for query. For possible options check es api * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException + * @throws InvalidException + * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function updateDocuments(array $docs, array $options = []): ResponseSet @@ -174,6 +187,10 @@ public function updateDocuments(array $docs, array $options = []): ResponseSet * @param array $options Optional params * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function updateByQuery($query, AbstractScript $script, array $options = []): Response { @@ -192,6 +209,10 @@ public function updateByQuery($query, AbstractScript $script, array $options = [ /** * Adds the given document to the search index. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function addDocument(Document $doc): Response { @@ -241,6 +262,12 @@ public function addDocument(Document $doc): Response * @param array|Document[] $docs Array of Elastica\Document * @param array $options Array of query params to use for query. For possible options check es api * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException + * @throws InvalidException + * * @return ResponseSet * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html @@ -260,8 +287,10 @@ public function addDocuments(array $docs, array $options = []) * @param int|string $id Document id * @param array $options options for the get request * - * @throws ResponseException * @throws NotFoundException + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function getDocument($id, array $options = []): Document { @@ -294,6 +323,10 @@ public function getDocument($id, array $options = []): Document * Deletes a document by its unique identifier. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function deleteById(string $id, array $options = []): Response { @@ -318,6 +351,10 @@ public function deleteById(string $id, array $options = []): Response * @param array $options Optional params * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function deleteByQuery($query, array $options = []): Response { @@ -334,6 +371,10 @@ public function deleteByQuery($query, array $options = []): Response * Opens a Point-in-Time on the index. * * @see: https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function openPointInTime(string $keepAlive): Response { @@ -345,6 +386,10 @@ public function openPointInTime(string $keepAlive): Response /** * Deletes the index. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function delete(): Response { @@ -356,6 +401,12 @@ public function delete(): Response * * @param Document[] $docs Array of documents * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * @throws BulkResponseException + * @throws InvalidException + * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function deleteDocuments(array $docs): ResponseSet @@ -375,6 +426,10 @@ public function deleteDocuments(array $docs): ResponseSet * @param array $args Additional arguments * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function forcemerge($args = []): Response { @@ -388,6 +443,10 @@ public function forcemerge($args = []): Response * Refreshes the index. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function refresh(): Response { @@ -403,6 +462,8 @@ public function refresh(): Response * @param array $options Associative array of options (option=>value) * * @throws InvalidException + * @throws ClientException + * @throws ConnectionException * @throws ResponseException * * @return Response Server response @@ -440,6 +501,10 @@ public function create(array $args = [], array $options = []): Response /** * Checks if the given index exists ans is created. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function exists(): bool { @@ -484,6 +549,10 @@ public function count($query = '', string $method = Request::POST): int * Opens an index. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function open(): Response { @@ -494,6 +563,10 @@ public function open(): Response * Closes the index. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function close(): Response { @@ -522,6 +595,10 @@ public function getClient(): Client * @param bool $replace If set, an existing alias will be replaced * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function addAlias(string $name, bool $replace = false): Response { @@ -547,6 +624,10 @@ public function addAlias(string $name, bool $replace = false): Response * Removes an alias pointing to the current index. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function removeAlias(string $name): Response { @@ -560,6 +641,10 @@ public function removeAlias(string $name): Response /** * Returns all index aliases. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return string[] */ public function getAliases(): array @@ -594,6 +679,10 @@ public function hasAlias(string $name): bool * Clears the cache of an index. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function clearCache(): Response { @@ -608,6 +697,10 @@ public function clearCache(): Response * Flushes the index to storage. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function flush(array $options = []): Response { @@ -623,6 +716,10 @@ public function flush(array $options = []): Response * @param array $data Data array * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function setSettings(array $data): Response { @@ -639,6 +736,10 @@ public function setSettings(array $data): Response * @param string $path Path to call * @param string $method Rest method to use (GET, POST, DELETE, PUT) * @param array|string $data Arguments as array or encoded string + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function request(string $path, string $method, $data = [], array $queryParameters = []): Response { @@ -649,6 +750,10 @@ public function request(string $path, string $method, $data = [], array $queryPa /** * Makes calls to the elasticsearch server with usage official client Endpoint based on this index. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function requestEndpoint(AbstractEndpoint $endpoint): Response { @@ -665,6 +770,10 @@ public function requestEndpoint(AbstractEndpoint $endpoint): Response * @param array $args Additional arguments * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function analyze(array $body, $args = []): array { diff --git a/src/Index/Settings.php b/src/Index/Settings.php index ebca0dc199..68d2e7e2fb 100644 --- a/src/Index/Settings.php +++ b/src/Index/Settings.php @@ -2,6 +2,8 @@ namespace Elastica\Index; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\NotFoundException; use Elastica\Exception\ResponseException; use Elastica\Index as BaseIndex; @@ -67,6 +69,10 @@ public function __construct(BaseIndex $index) * * @param string $setting OPTIONAL Setting name to return * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return array|int|string|null Settings data * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html @@ -302,6 +308,10 @@ public function getMergePolicy(string $key) * * @param array $data Arguments * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response Response object */ public function set(array $data): Response @@ -335,6 +345,10 @@ public function getIndex(): BaseIndex * @param array $data OPTIONAL Data array * @param string $method OPTIONAL Transfer method (default = \Elastica\Request::GET) * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response Response object */ public function request(array $data = [], string $method = Request::GET, array $queryParameters = []): Response diff --git a/src/IndexTemplate.php b/src/IndexTemplate.php index 10f4aa201f..58ea468ea1 100644 --- a/src/IndexTemplate.php +++ b/src/IndexTemplate.php @@ -2,7 +2,10 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; /** * Elastica index template object. @@ -45,6 +48,10 @@ public function __construct(Client $client, $name) /** * Deletes the index template. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function delete() @@ -59,6 +66,10 @@ public function delete() * * @param array $args OPTIONAL Arguments to use * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function create(array $args = []) @@ -69,6 +80,10 @@ public function create(array $args = []) /** * Checks if the given index template is already created. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return bool */ public function exists() @@ -104,6 +119,10 @@ public function getClient() * @param string $method Rest method to use (GET, POST, DELETE, PUT) * @param array $data OPTIONAL Arguments as array * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function request($method, $data = []) diff --git a/src/Node/Info.php b/src/Node/Info.php index 49323f8209..8989218a9d 100644 --- a/src/Node/Info.php +++ b/src/Node/Info.php @@ -2,6 +2,9 @@ namespace Elastica\Node; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\ResponseException; use Elastica\Node as BaseNode; use Elastica\Response; use Elasticsearch\Endpoints\Nodes\Info as NodesInfo; @@ -204,6 +207,10 @@ public function getResponse(): Response * * @param array $params Params to return (default none). Possible options: settings, os, process, jvm, thread_pool, network, transport, http, plugin * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response Response object */ public function refresh(array $params = []): Response diff --git a/src/Node/Stats.php b/src/Node/Stats.php index 1586602249..b975e616a5 100644 --- a/src/Node/Stats.php +++ b/src/Node/Stats.php @@ -2,6 +2,9 @@ namespace Elastica\Node; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\ResponseException; use Elastica\Node as BaseNode; use Elastica\Response; use Elasticsearch\Endpoints\Nodes\Stats as NodesStats; @@ -103,6 +106,10 @@ public function getResponse(): Response /** * Reloads all nodes information. Has to be called if informations changed. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response Response object */ public function refresh(): Response diff --git a/src/Pipeline.php b/src/Pipeline.php index b9fd2a3eea..45697b590a 100644 --- a/src/Pipeline.php +++ b/src/Pipeline.php @@ -2,7 +2,10 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; use Elastica\Processor\AbstractProcessor; use Elasticsearch\Endpoints\AbstractEndpoint; use Elasticsearch\Endpoints\Ingest\DeletePipeline; @@ -172,6 +175,10 @@ public function getClient(): Client /** * Makes calls to the elasticsearch server with usage official client Endpoint based on this index. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function requestEndpoint(AbstractEndpoint $endpoint): Response { diff --git a/src/Reindex.php b/src/Reindex.php index 05cc2698c3..ef429907fd 100644 --- a/src/Reindex.php +++ b/src/Reindex.php @@ -2,6 +2,9 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\ResponseException; use Elastica\Query\AbstractQuery; use Elastica\Script\AbstractScript; use Elastica\Script\Script; @@ -63,6 +66,11 @@ public function __construct(Index $oldIndex, Index $newIndex, array $params = [] $this->setParams($params); } + /** + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + */ public function run(): Response { $body = $this->_getBody($this->_oldIndex, $this->_newIndex, $this->getParams()); diff --git a/src/Scroll.php b/src/Scroll.php index c65c25d2b9..297602e327 100644 --- a/src/Scroll.php +++ b/src/Scroll.php @@ -2,7 +2,10 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; /** * Scroll Iterator. @@ -69,6 +72,10 @@ public function current(): ResultSet * Next scroll search. * * @see http://php.net/manual/en/iterator.next.php + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function next(): void { @@ -112,6 +119,10 @@ public function valid(): bool * Initial scroll search. * * @see http://php.net/manual/en/iterator.rewind.php + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function rewind(): void { @@ -132,6 +143,10 @@ public function rewind(): void /** * Cleares the search context on ES and marks this Scroll instance as finished. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function clear(): void { @@ -149,6 +164,10 @@ public function clear(): void /** * Prepares Scroll for next request. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ protected function _setScrollId(ResultSet $resultSet): void { diff --git a/src/Search.php b/src/Search.php index 0b9310cb71..826f179657 100644 --- a/src/Search.php +++ b/src/Search.php @@ -2,6 +2,8 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; use Elastica\Exception\ResponseException; use Elastica\Query\AbstractQuery; @@ -281,6 +283,8 @@ public function getPath(): string * @param array|null $options associative array of options (option=>value) * * @throws InvalidException + * @throws ClientException + * @throws ConnectionException * @throws ResponseException */ public function search($query = '', ?array $options = null, string $method = Request::POST): ResultSet @@ -309,6 +313,10 @@ public function search($query = '', ?array $options = null, string $method = Req * @param array|Query|Query\AbstractQuery|string $query * @param bool $fullResult By default only the total hit count is returned. If set to true, the full ResultSet including aggregations is returned * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return int|ResultSet */ public function count($query = '', bool $fullResult = false, string $method = Request::POST) diff --git a/src/SearchableInterface.php b/src/SearchableInterface.php index 3d38370b27..4e94427fc0 100644 --- a/src/SearchableInterface.php +++ b/src/SearchableInterface.php @@ -2,6 +2,10 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; use Elastica\Query\AbstractQuery; use Elastica\Suggest\AbstractSuggest; @@ -37,6 +41,11 @@ interface SearchableInterface * * @param array|null $options associative array of options (option=>value) * @param string $method Request method, see Request's constants + * + * @throws ClientException + * @throws ConnectionException + * @throws InvalidException + * @throws ResponseException */ public function search($query = '', ?array $options = null, string $method = Request::POST): ResultSet; @@ -51,6 +60,10 @@ public function search($query = '', ?array $options = null, string $method = Req * * @param string $method Request method, see Request's constants * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return int number of documents matching the query */ public function count($query = '', string $method = Request::POST); diff --git a/src/Snapshot.php b/src/Snapshot.php index 05fa48357a..f030e5e305 100644 --- a/src/Snapshot.php +++ b/src/Snapshot.php @@ -2,6 +2,8 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\NotFoundException; use Elastica\Exception\ResponseException; use Elasticsearch\Endpoints\Snapshot\Restore; @@ -30,6 +32,10 @@ public function __construct(Client $client) * @param string $type the repository type ("fs" for file system) * @param array $settings Additional repository settings. If type "fs" is used, the "location" setting must be provided. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function registerRepository($name, $type, $settings = []) @@ -47,8 +53,10 @@ public function registerRepository($name, $type, $settings = []) * * @param string $name the name of the desired repository * - * @throws Exception\ResponseException - * @throws Exception\NotFoundException + * @throws ClientException + * @throws ConnectionException + * @throws NotFoundException + * @throws ResponseException * * @return array */ @@ -70,6 +78,10 @@ public function getRepository($name) /** * Retrieve all repository records. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return array */ public function getAllRepositories() @@ -85,6 +97,10 @@ public function getAllRepositories() * @param array $options optional settings for this snapshot * @param bool $waitForCompletion if true, the request will not return until the snapshot operation is complete * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function createSnapshot($repository, $name, $options = [], $waitForCompletion = false) @@ -98,8 +114,10 @@ public function createSnapshot($repository, $name, $options = [], $waitForComple * @param string $repository the name of the repository from which to retrieve the snapshot * @param string $name the name of the desired snapshot * - * @throws Exception\ResponseException - * @throws Exception\NotFoundException + * @throws ClientException + * @throws ConnectionException + * @throws NotFoundException + * @throws ResponseException * * @return array */ @@ -123,6 +141,10 @@ public function getSnapshot($repository, $name) * * @param string $repository the repository name * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return array */ public function getAllSnapshots($repository) @@ -136,6 +158,10 @@ public function getAllSnapshots($repository) * @param string $repository the repository in which the snapshot resides * @param string $name the name of the snapshot to be deleted * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function deleteSnapshot($repository, $name) @@ -151,6 +177,10 @@ public function deleteSnapshot($repository, $name) * @param array $options options for the restore operation * @param bool $waitForCompletion if true, the request will not return until the restore operation is complete * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function restoreSnapshot($repository, $name, $options = [], $waitForCompletion = false) @@ -175,6 +205,10 @@ public function restoreSnapshot($repository, $name, $options = [], $waitForCompl * @param array $data request body data * @param array $query query string parameters * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Response */ public function request($path, $method = Request::GET, $data = [], array $query = []) diff --git a/src/Status.php b/src/Status.php index ce5d55d88e..f8f6371d5b 100644 --- a/src/Status.php +++ b/src/Status.php @@ -2,6 +2,8 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; use Elastica\Exception\ResponseException; use Elasticsearch\Endpoints\Indices\Alias\Get; use Elasticsearch\Endpoints\Indices\GetAlias; @@ -91,6 +93,10 @@ public function aliasExists(string $name) /** * Returns an array with all indices that the given alias name points to. * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException + * * @return Index[] */ public function getIndicesWithAlias(string $alias) @@ -147,6 +153,10 @@ public function getShards() /** * Refresh status object. + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function refresh(): void { diff --git a/src/Task.php b/src/Task.php index b0e84e2576..9546c24682 100644 --- a/src/Task.php +++ b/src/Task.php @@ -2,6 +2,9 @@ namespace Elastica; +use Elastica\Exception\ClientException; +use Elastica\Exception\ConnectionException; +use Elastica\Exception\ResponseException; use Elasticsearch\Endpoints\Tasks; /** @@ -83,6 +86,10 @@ public function getResponse(): Response * Refresh task status. * * @param array $options + * + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function refresh(array $options = []): void { @@ -102,6 +109,9 @@ public function isCompleted(): bool return true === $data['completed']; } + /** + * @throws \Exception + */ public function cancel(): Response { if ('' === $this->_id) {