Skip to content

Commit

Permalink
Add missing throws exception
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jun 17, 2022
1 parent 682b78d commit baf09f3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 25 additions & 1 deletion src/AbstractUpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -55,7 +57,7 @@ public function setIndex($index): self
/**
* Get the document index name.
*
* @throws \Elastica\Exception\InvalidException
* @throws InvalidException
*
* @return string Index name
*/
Expand Down Expand Up @@ -103,6 +105,8 @@ public function setSequenceNumber(int $number): self
/**
* Returns document version.
*
* @throws InvalidException
*
* @return int Document version
*/
public function getSequenceNumber(): int
Expand Down Expand Up @@ -132,6 +136,8 @@ public function setPrimaryTerm(int $term): self
/**
* Returns document version.
*
* @throws InvalidException
*
* @return int Document version
*/
public function getPrimaryTerm(): int
Expand Down Expand Up @@ -161,6 +167,8 @@ public function setVersion($version)
/**
* Returns document version.
*
* @throws InvalidException
*
* @return int|string Document version
*/
public function getVersion()
Expand Down Expand Up @@ -191,6 +199,8 @@ public function setOpType($opType)
/**
* Get operation type.
*
* @throws InvalidException
*
* @return string
*/
public function getOpType()
Expand Down Expand Up @@ -221,6 +231,8 @@ public function setRouting($value)
/**
* Get routing parameter.
*
* @throws InvalidException
*
* @return string
*/
public function getRouting()
Expand Down Expand Up @@ -259,6 +271,8 @@ public function setFieldsSource()
}

/**
* @throws InvalidException
*
* @return string
*/
public function getFields()
Expand All @@ -285,6 +299,8 @@ public function setRetryOnConflict($num)
}

/**
* @throws InvalidException
*
* @return int
*/
public function getRetryOnConflict()
Expand Down Expand Up @@ -317,6 +333,8 @@ public function setRefresh($refresh = true)
}

/**
* @throws InvalidException
*
* @return bool|string
*/
public function getRefresh()
Expand Down Expand Up @@ -347,6 +365,8 @@ public function setTimeout($timeout)
}

/**
* @throws InvalidException
*
* @return bool
*/
public function getTimeout()
Expand All @@ -373,6 +393,8 @@ public function setConsistency($timeout)
}

/**
* @throws InvalidException
*
* @return string
*/
public function getConsistency()
Expand All @@ -399,6 +421,8 @@ public function setReplication($timeout)
}

/**
* @throws InvalidException
*
* @return string
*/
public function getReplication()
Expand Down
8 changes: 6 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
{
Expand Down
5 changes: 5 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Elastica;

use Elastica\Exception\ConnectionException;
use Elastica\Exception\InvalidException;
use GuzzleHttp\Exception\RequestException;

/**
* Elastica Request object.
Expand Down Expand Up @@ -169,6 +171,9 @@ public function getContentType(): string

/**
* Sends request to server.
*
* @throws RequestException
* @throws ConnectionException
*/
public function send(): Response
{
Expand Down
2 changes: 2 additions & 0 deletions src/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Elastica;

use Elastica\Exception\InvalidException;
use Elastica\Exception\ResponseException;
use Elastica\ResultSet\BuilderInterface;
use Elastica\ResultSet\DefaultBuilder;

Expand Down Expand Up @@ -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
{
Expand Down
5 changes: 5 additions & 0 deletions src/Transport/AbstractTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit baf09f3

Please sign in to comment.