From 9b2c42a82beab4ce13100de7294eb49a956186d6 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Fri, 17 Jun 2022 17:41:44 +0200 Subject: [PATCH] Add missing throws exception --- CHANGELOG.md | 1 + src/AbstractUpdateAction.php | 26 +++++++++++++++++++++++++- src/Client.php | 8 ++++++-- src/Request.php | 5 +++++ src/Search.php | 2 ++ src/Transport/AbstractTransport.php | 5 +++++ 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65fbb5fb7a..3ce41f7ab8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Added `PHPStan` at level 3 by @franmomu [#2064](https://github.com/ruflin/Elastica/pull/2064) * Added coverage check to CI by @franmomu [#2071](https://github.com/ruflin/Elastica/pull/2071) +* Added missing `throws` PHPDoc tags ### Changed * Updated `symfony/phpunit-bridge` to `6.0` by @franmomu [#2067](https://github.com/ruflin/Elastica/pull/2067) * Updated `php-cs-fixer` to `3.8.0` [#2074](https://github.com/ruflin/Elastica/pull/2074) diff --git a/src/AbstractUpdateAction.php b/src/AbstractUpdateAction.php index 74b186949c..009a12cfc6 100644 --- a/src/AbstractUpdateAction.php +++ b/src/AbstractUpdateAction.php @@ -2,6 +2,8 @@ namespace Elastica; +use Elastica\Exception\InvalidException; + /** * Base class for things that can be sent to the update api (Document and * Script). @@ -55,7 +57,7 @@ public function setIndex($index): self /** * Get the document index name. * - * @throws \Elastica\Exception\InvalidException + * @throws InvalidException * * @return string Index name */ @@ -103,6 +105,8 @@ public function setSequenceNumber(int $number): self /** * Returns document version. * + * @throws InvalidException + * * @return int Document version */ public function getSequenceNumber(): int @@ -132,6 +136,8 @@ public function setPrimaryTerm(int $term): self /** * Returns document version. * + * @throws InvalidException + * * @return int Document version */ public function getPrimaryTerm(): int @@ -161,6 +167,8 @@ public function setVersion($version) /** * Returns document version. * + * @throws InvalidException + * * @return int|string Document version */ public function getVersion() @@ -191,6 +199,8 @@ public function setOpType($opType) /** * Get operation type. * + * @throws InvalidException + * * @return string */ public function getOpType() @@ -221,6 +231,8 @@ public function setRouting($value) /** * Get routing parameter. * + * @throws InvalidException + * * @return string */ public function getRouting() @@ -259,6 +271,8 @@ public function setFieldsSource() } /** + * @throws InvalidException + * * @return string */ public function getFields() @@ -285,6 +299,8 @@ public function setRetryOnConflict($num) } /** + * @throws InvalidException + * * @return int */ public function getRetryOnConflict() @@ -317,6 +333,8 @@ public function setRefresh($refresh = true) } /** + * @throws InvalidException + * * @return bool|string */ public function getRefresh() @@ -347,6 +365,8 @@ public function setTimeout($timeout) } /** + * @throws InvalidException + * * @return bool */ public function getTimeout() @@ -373,6 +393,8 @@ public function setConsistency($timeout) } /** + * @throws InvalidException + * * @return string */ public function getConsistency() @@ -399,6 +421,8 @@ public function setReplication($timeout) } /** + * @throws InvalidException + * * @return string */ public function getReplication() diff --git a/src/Client.php b/src/Client.php index defb9c586b..01b7d3f755 100644 --- a/src/Client.php +++ b/src/Client.php @@ -4,8 +4,10 @@ use Elastica\Bulk\Action; use Elastica\Bulk\ResponseSet; +use Elastica\Exception\ClientException; use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; use Elastica\Script\AbstractScript; use Elasticsearch\Endpoints\AbstractEndpoint; use Elasticsearch\Endpoints\ClosePointInTime; @@ -474,7 +476,7 @@ public function deleteIds(array $ids, $index, $routing = false): ResponseSet * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * - * @throws \Elastica\Exception\ResponseException + * @throws ResponseException * @throws InvalidException */ public function bulk(array $params): ResponseSet @@ -501,7 +503,9 @@ public function bulk(array $params): ResponseSet * @param array $query OPTIONAL Query params * @param string $contentType Content-Type sent with this request * - * @throws Exception\ClientException|Exception\ConnectionException + * @throws ClientException + * @throws ConnectionException + * @throws ResponseException */ public function request(string $path, string $method = Request::GET, $data = [], array $query = [], string $contentType = Request::DEFAULT_CONTENT_TYPE): Response { diff --git a/src/Request.php b/src/Request.php index b5cc76395c..071b053ff4 100644 --- a/src/Request.php +++ b/src/Request.php @@ -2,7 +2,9 @@ namespace Elastica; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; /** * Elastica Request object. @@ -169,6 +171,9 @@ public function getContentType(): string /** * Sends request to server. + * + * @throws ResponseException + * @throws ConnectionException */ public function send(): Response { diff --git a/src/Search.php b/src/Search.php index 3866829d02..7fbee07f47 100644 --- a/src/Search.php +++ b/src/Search.php @@ -3,6 +3,7 @@ namespace Elastica; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; use Elastica\ResultSet\BuilderInterface; use Elastica\ResultSet\DefaultBuilder; @@ -257,6 +258,7 @@ public function getPath(): string * @param array|int $options Limit or associative array of options (option=>value) * * @throws InvalidException + * @throws ResponseException */ public function search($query = '', $options = null, string $method = Request::POST): ResultSet { diff --git a/src/Transport/AbstractTransport.php b/src/Transport/AbstractTransport.php index a31a2783df..dcdbf3368c 100644 --- a/src/Transport/AbstractTransport.php +++ b/src/Transport/AbstractTransport.php @@ -3,7 +3,9 @@ namespace Elastica\Transport; use Elastica\Connection; +use Elastica\Exception\ConnectionException; use Elastica\Exception\InvalidException; +use Elastica\Exception\ResponseException; use Elastica\Param; use Elastica\Request; use Elastica\Response; @@ -50,6 +52,9 @@ public function setConnection(Connection $connection): AbstractTransport * * @param Request $request Request object * @param array $params Hostname, port, path, ... + * + * @throws ResponseException + * @throws ConnectionException */ abstract public function exec(Request $request, array $params): Response;