Skip to content

Commit

Permalink
Specify some iterable types (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu authored Jun 27, 2022
1 parent ae21282 commit 7e4de1e
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `ExceptionInterface` extends `Throwable` [#2083](https://github.com/ruflin/Elastica/pull/2083)
* Changed `value` in `SetProcessor` to accept `mixed` instead of `string` by @franmomu [#2082](https://github.com/ruflin/Elastica/pull/2082)
* Updated `Query::create` PHPDoc to include supported types and propagate it to callers by @franmomu [#2088](https://github.com/ruflin/Elastica/pull/2088)
* Update some iterable types in PHPDoc to be more specific by @franmomu [#2092](https://github.com/ruflin/Elastica/pull/2092)

### Deprecated
* Deprecated `Elastica\Reindex::WAIT_FOR_COMPLETION_FALSE`, use a boolean as parameter instead by @franmomu [#2070](https://github.com/ruflin/Elastica/pull/2070)
Expand Down
6 changes: 3 additions & 3 deletions src/Param.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class Param implements ArrayableInterface, \Countable
/**
* Params.
*
* @var array|\stdClass
* @var array<string, mixed>|\stdClass
*/
protected $_params = [];

/**
* Raw Params.
*
* @var array
* @var array<string, mixed>
*/
protected $_rawParams = [];

Expand All @@ -32,7 +32,7 @@ class Param implements ArrayableInterface, \Countable
* the an array out of the class name (last part of the class name)
* and the params.
*
* @return array Filter array
* @return array<string, mixed> Filter array
*/
public function toArray()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function getStatus()
/**
* Response data array.
*
* @return array Response data array
* @return array<string, mixed> Response data array
*/
public function getData()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Status
/**
* Data.
*
* @var array Data
* @var array<string, mixed> Data
*/
protected $_data;

Expand All @@ -43,7 +43,7 @@ public function __construct(Client $client)
/**
* Returns status data.
*
* @return array Status data
* @return array<string, mixed> Status data
*/
public function getData()
{
Expand Down Expand Up @@ -136,7 +136,7 @@ public function getResponse()
/**
* Return shards info.
*
* @return array Shards info
* @return array<string, mixed> Shards info
*/
public function getShards()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Suggest/AbstractSuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public function setRegex(string $regex): self
* Expects one of the next params: max_determinized_states - defaults to 10000,
* flags are ALL (default), ANYSTRING, COMPLEMENT, EMPTY, INTERSECTION, INTERVAL, or NONE.
*
* @phpstan-param array{
* max_determinized_states?: int,
* flags: 'ALL'|'ANYSTRING'|'COMPLEMENT'|'EMPTY'|'INTERSECTION'|'INTERVAL'|'NONE'
* } $value
*
* @return $this
*/
public function setRegexOptions(array $value): self
Expand Down
2 changes: 2 additions & 0 deletions src/Suggest/Completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Completion extends AbstractSuggest
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html#fuzzy
*
* @param array<string, mixed> $fuzzy
*
* @return $this
*/
public function setFuzzy(array $fuzzy): Completion
Expand Down
3 changes: 2 additions & 1 deletion src/Suggest/Phrase.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public function setLinearInterpolationSmoothing(float $trigramLambda, float $big
}

/**
* @param string $model the name of the smoothing model
* @param string $model the name of the smoothing model
* @param array<string, mixed> $params
*
* @return $this
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Task extends Param
protected $_response;

/**
* @var array
* @var array<string, mixed>
*/
protected $_data;

Expand All @@ -55,6 +55,8 @@ public function getId()

/**
* Returns task data.
*
* @return array<string, mixed>
*/
public function getData(): array
{
Expand All @@ -79,6 +81,8 @@ public function getResponse(): Response

/**
* Refresh task status.
*
* @param array<string, mixed> $options
*/
public function refresh(array $options = []): void
{
Expand Down
14 changes: 8 additions & 6 deletions src/Transport/AbstractTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function setConnection(Connection $connection): AbstractTransport
/**
* Executes the transport request.
*
* @param Request $request Request object
* @param array $params Hostname, port, path, ...
* @param Request $request Request object
* @param array<string, mixed> $params Hostname, port, path, ...
*
* @throws ResponseException
* @throws ConnectionException
Expand All @@ -62,7 +62,9 @@ abstract public function exec(Request $request, array $params): Response;
* BOOL values true|false should be sanityzed and passed to Elasticsearch
* as string.
*
* @return array
* @param array<string, mixed> $query
*
* @return array<string, mixed>
*/
public function sanityzeQueryStringBool(array $query)
{
Expand All @@ -85,9 +87,9 @@ public function sanityzeQueryStringBool(array $query)
* * array: An array with a "type" key which must be set to one of the two options. All other
* keys in the array will be set as parameters in the transport instance
*
* @param mixed $transport A transport definition
* @param Connection $connection A connection instance
* @param array $params Parameters for the transport class
* @param AbstractTransport|array<string, mixed>|string $transport A transport definition
* @param Connection $connection A connection instance
* @param array<string, mixed> $params Parameters for the transport class
*
* @throws InvalidException
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Transport/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ protected function _getActionPath(Request $request): string
return $action;
}

/**
* @param mixed $data
*/
private function streamFor($data): StreamInterface
{
if (\is_array($data)) {
Expand Down
5 changes: 4 additions & 1 deletion src/Transport/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Http extends AbstractTransport
*
* All calls that are made to the server are done through this function
*
* @param array $params Host, Port, ...
* @param array<string, mixed> $params Host, Port, ...
*
* @throws ConnectionException
* @throws ResponseException
Expand Down Expand Up @@ -219,6 +219,9 @@ protected function _getConnection(bool $persistent = true)
return self::$_curlConnection;
}

/**
* @return int
*/
protected function _getAuthType()
{
switch ($this->_connection->getAuthType()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/HttpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(?Connection $connection, HttpAdapterInterface $httpA
*
* All calls that are made to the server are done through this function
*
* @param array $params Host, Port, ...
* @param array<string, mixed> $params Host, Port, ...
*
* @throws \Elastica\Exception\ConnectionException
* @throws ResponseException
Expand Down
6 changes: 3 additions & 3 deletions src/Transport/NullTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NullTransport extends AbstractTransport
/**
* Set response object the transport returns.
*
* @param array $params Hostname, port, path, ...
* @param array<string, mixed> $params Hostname, port, path, ...
*/
public function getResponse(array $params = []): Response
{
Expand All @@ -49,7 +49,7 @@ public function setResponse(Response $response): NullTransport
/**
* Generate an example response object.
*
* @param array $params Hostname, port, path, ...
* @param array<string, mixed> $params Hostname, port, path, ...
*
* @return Response $response
*/
Expand Down Expand Up @@ -79,7 +79,7 @@ public function generateDefaultResponse(array $params): Response
/**
* Null transport.
*
* @param array $params Hostname, port, path, ...
* @param array<string, mixed> $params Hostname, port, path, ...
*
* @return Response Response empty object
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
*/
class Util
{
/** @var array */
/** @var list<string> */
protected static $dateMathSymbols = ['<', '>', '/', '{', '}', '|', '+', ':', ','];

/** @var array */
/** @var list<string> */
protected static $escapedDateMathSymbols = ['%3C', '%3E', '%2F', '%7B', '%7D', '%7C', '%2B', '%3A', '%2C'];

/**
Expand Down

0 comments on commit 7e4de1e

Please sign in to comment.