diff --git a/CHANGELOG.md b/CHANGELOG.md index b073752956..d9f8f42c09 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,9 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Removed `0` as valid request data using Analyze API by @franmomu [#2068](https://github.com/ruflin/Elastica/pull/2068) * Removed dead code in `AwsAuthV4Test` by @franmomu [#2073](https://github.com/ruflin/Elastica/pull/2073) ### Fixed -* Fixed some PHPDoc types adding `null` as possible value by @franmomu [#2070](https://github.com/ruflin/Elastica/pull/2070) +* Fixed some PHPDoc types adding `null` as possible value by @franmomu [#2070](https://github.com/ruflin/Elastica/pull/2070) and [#2087](https://github.com/ruflin/Elastica/pull/2087) * Fixed passing wrong types to `GapPolicyInterface::setGapPolicy()`, `Document::setDocAsUpsert()` and `Connection::setPort()` methods by @franmomu [#2081](https://github.com/ruflin/Elastica/pull/2081) * Fixed `Http` PHPDoc adding `\CurlHandle` type for Curl connection by @franmomu [#2086](https://github.com/ruflin/Elastica/pull/2086) +* Fixed case mismatch in method calls by @franmomu [#2087](https://github.com/ruflin/Elastica/pull/2087) ### Security diff --git a/src/Aggregation/GeoDistance.php b/src/Aggregation/GeoDistance.php index 0e9b2e8ea1..a85309bbbf 100644 --- a/src/Aggregation/GeoDistance.php +++ b/src/Aggregation/GeoDistance.php @@ -57,8 +57,8 @@ public function setOrigin($origin): self /** * Add a distance range to this aggregation. * - * @param int $fromValue a distance - * @param int $toValue a distance + * @param int|null $fromValue a distance + * @param int|null $toValue a distance * * @throws InvalidException * diff --git a/src/Aggregation/IpRange.php b/src/Aggregation/IpRange.php index 7beeb25018..ac78dcdbd9 100644 --- a/src/Aggregation/IpRange.php +++ b/src/Aggregation/IpRange.php @@ -38,8 +38,8 @@ public function setField(string $field): self /** * Add an ip range to this aggregation. * - * @param string $fromValue a valid ipv4 address. Low end of this range, exclusive (greater than) - * @param string $toValue a valid ipv4 address. High end of this range, exclusive (less than) + * @param string|null $fromValue a valid ipv4 address. Low end of this range, exclusive (greater than) + * @param string|null $toValue a valid ipv4 address. High end of this range, exclusive (less than) * * @throws InvalidException * diff --git a/src/Aggregation/Percentiles.php b/src/Aggregation/Percentiles.php index c4c1d3a94c..8fc717f6ea 100644 --- a/src/Aggregation/Percentiles.php +++ b/src/Aggregation/Percentiles.php @@ -13,8 +13,8 @@ class Percentiles extends AbstractSimpleAggregation use Traits\MissingTrait; /** - * @param string $name the name of this aggregation - * @param string $field the field on which to perform this aggregation + * @param string $name the name of this aggregation + * @param string|null $field the field on which to perform this aggregation */ public function __construct(string $name, ?string $field = null) { diff --git a/src/Aggregation/ReverseNested.php b/src/Aggregation/ReverseNested.php index a7b261b4af..b1f059451e 100644 --- a/src/Aggregation/ReverseNested.php +++ b/src/Aggregation/ReverseNested.php @@ -10,8 +10,8 @@ class ReverseNested extends AbstractAggregation { /** - * @param string $name The name of this aggregation - * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. + * @param string $name The name of this aggregation + * @param string|null $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. */ public function __construct(string $name, ?string $path = null) { diff --git a/src/Bulk/Action.php b/src/Bulk/Action.php index 867edf0d68..d97fd82aeb 100644 --- a/src/Bulk/Action.php +++ b/src/Bulk/Action.php @@ -34,7 +34,7 @@ class Action protected $_metadata = []; /** - * @var array + * @var array|string */ protected $_source = []; diff --git a/src/Client.php b/src/Client.php index 01b7d3f755..a59b13bc43 100644 --- a/src/Client.php +++ b/src/Client.php @@ -264,7 +264,7 @@ public function addDocuments(array $docs, array $requestParams = []): ResponseSe public function updateDocument($id, $data, $index, array $options = []): Response { $endpoint = new Update(); - $endpoint->setID($id); + $endpoint->setId($id); $endpoint->setIndex($index); if ($data instanceof AbstractScript) { @@ -387,7 +387,7 @@ public function hasConnection() } /** - * @throws \Elastica\Exception\ClientException + * @throws ClientException * * @return Connection */ diff --git a/src/Exception/Connection/HttpException.php b/src/Exception/Connection/HttpException.php index 3739acf45a..652ab7d82d 100644 --- a/src/Exception/Connection/HttpException.php +++ b/src/Exception/Connection/HttpException.php @@ -23,9 +23,7 @@ class HttpException extends ConnectionException /** * Construct Exception. * - * @param int $error - * @param Request $request - * @param Response $response + * @param int $error */ public function __construct($error, ?Request $request = null, ?Response $response = null) { diff --git a/src/Index.php b/src/Index.php index fbadaadfb5..fd6cc96420 100644 --- a/src/Index.php +++ b/src/Index.php @@ -193,7 +193,7 @@ public function addDocument(Document $doc): Response $endpoint = new IndexEndpoint(); if (null !== $doc->getId() && '' !== $doc->getId()) { - $endpoint->setID($doc->getId()); + $endpoint->setId($doc->getId()); } $options = $doc->getOptions( @@ -261,7 +261,7 @@ public function addDocuments(array $docs, array $options = []) public function getDocument($id, array $options = []): Document { $endpoint = new DocumentGet(); - $endpoint->setID($id); + $endpoint->setId($id); $endpoint->setParams($options); $response = $this->requestEndpoint($endpoint); @@ -297,7 +297,7 @@ public function deleteById(string $id, array $options = []): Response } $endpoint = new \Elasticsearch\Endpoints\Delete(); - $endpoint->setID(\trim($id)); + $endpoint->setId(\trim($id)); $endpoint->setParams($options); return $this->requestEndpoint($endpoint); @@ -457,7 +457,6 @@ public function exists(): bool /** * @param AbstractQuery|array|Collapse|Query|string|Suggest $query * @param array|int $options - * @param BuilderInterface $builder */ public function createSearch($query = '', $options = null, ?BuilderInterface $builder = null): Search { diff --git a/src/Index/Recovery.php b/src/Index/Recovery.php index e3afb33e60..2378fd2bcc 100644 --- a/src/Index/Recovery.php +++ b/src/Index/Recovery.php @@ -90,7 +90,7 @@ public function refresh(): self } /** - * @return mixed + * @return array */ protected function getRecoveryData() { diff --git a/src/Node/Info.php b/src/Node/Info.php index d4d35080f5..49323f8209 100644 --- a/src/Node/Info.php +++ b/src/Node/Info.php @@ -212,7 +212,7 @@ public function refresh(array $params = []): Response // TODO: Use only NodesInfo when dropping support for elasticsearch/elasticsearch 7.x $endpoint = \class_exists(NodesInfo::class) ? new NodesInfo() : new \Elasticsearch\Endpoints\Cluster\Nodes\Info(); - $endpoint->setNodeID($this->getNode()->getId()); + $endpoint->setNodeId($this->getNode()->getId()); if ($params) { $endpoint->setMetric($params); diff --git a/src/Node/Stats.php b/src/Node/Stats.php index e60ca6624f..1586602249 100644 --- a/src/Node/Stats.php +++ b/src/Node/Stats.php @@ -109,7 +109,7 @@ public function refresh(): Response { // TODO: Use only NodesStats when dropping support for elasticsearch/elasticsearch 7.x $endpoint = \class_exists(NodesStats::class) ? new NodesStats() : new \Elasticsearch\Endpoints\Cluster\Nodes\Stats(); - $endpoint->setNodeID($this->getNode()->getName()); + $endpoint->setNodeId($this->getNode()->getName()); $this->_response = $this->getNode()->getClient()->requestEndpoint($endpoint); $data = $this->getResponse()->getData(); diff --git a/src/Pipeline.php b/src/Pipeline.php index 48234c5da4..80c29c21f8 100644 --- a/src/Pipeline.php +++ b/src/Pipeline.php @@ -65,7 +65,7 @@ public function create(): Response // TODO: Use only PutPipeline when dropping support for elasticsearch/elasticsearch 7.x $endpoint = \class_exists(PutPipeline::class) ? new PutPipeline() : new Put(); - $endpoint->setID($this->id); + $endpoint->setId($this->id); $endpoint->setBody($this->toArray()); return $this->requestEndpoint($endpoint); @@ -80,7 +80,7 @@ public function getPipeline(string $id): Response { // TODO: Use only GetPipeline when dropping support for elasticsearch/elasticsearch 7.x $endpoint = \class_exists(GetPipeline::class) ? new GetPipeline() : new Get(); - $endpoint->setID($id); + $endpoint->setId($id); return $this->requestEndpoint($endpoint); } @@ -94,7 +94,7 @@ public function deletePipeline(string $id): Response { // TODO: Use only DeletePipeline when dropping support for elasticsearch/elasticsearch 7.x $endpoint = \class_exists(DeletePipeline::class) ? new DeletePipeline() : new Delete(); - $endpoint->setID($id); + $endpoint->setId($id); return $this->requestEndpoint($endpoint); } diff --git a/src/Query/FunctionScore.php b/src/Query/FunctionScore.php index 5b4256fb9d..9f46d4b36b 100644 --- a/src/Query/FunctionScore.php +++ b/src/Query/FunctionScore.php @@ -65,8 +65,8 @@ public function setQuery(AbstractQuery $query): self * * @param string $functionType valid values are DECAY_* constants and script_score * @param AbstractScript|array|float $functionParams the body of the function. See documentation for proper syntax. - * @param AbstractQuery $filter filter to apply to the function - * @param float $weight function weight + * @param AbstractQuery|null $filter filter to apply to the function + * @param float|null $weight function weight * * @return $this */ @@ -96,9 +96,9 @@ public function addFunction( /** * Add a script_score function to the query. * - * @param AbstractScript $script a Script object - * @param AbstractQuery $filter an optional filter to apply to the function - * @param float $weight the weight of the function + * @param AbstractScript $script a Script object + * @param AbstractQuery|null $filter an optional filter to apply to the function + * @param float|null $weight the weight of the function * * @return $this */ @@ -110,15 +110,15 @@ public function addScriptScoreFunction(AbstractScript $script, ?AbstractQuery $f /** * Add a decay function to the query. * - * @param string $function see DECAY_* constants for valid options - * @param string $field the document field on which to perform the decay function - * @param string $origin the origin value for this decay function - * @param string $scale a scale to define the rate of decay for this function - * @param string $offset If defined, this function will only be computed for documents with a distance from the origin greater than this value - * @param float $decay optionally defines how documents are scored at the distance given by the $scale parameter - * @param float $weight optional factor by which to multiply the score at the value provided by the $scale parameter - * @param AbstractQuery $filter a filter associated with this function - * @param string $multiValueMode see MULTI_VALUE_MODE_* constants for valid options + * @param string $function see DECAY_* constants for valid options + * @param string $field the document field on which to perform the decay function + * @param string $origin the origin value for this decay function + * @param string $scale a scale to define the rate of decay for this function + * @param string|null $offset If defined, this function will only be computed for documents with a distance from the origin greater than this value + * @param float|null $decay optionally defines how documents are scored at the distance given by the $scale parameter + * @param float|null $weight optional factor by which to multiply the score at the value provided by the $scale parameter + * @param AbstractQuery|null $filter a filter associated with this function + * @param string|null $multiValueMode see MULTI_VALUE_MODE_* constants for valid options * * @return $this */ @@ -184,8 +184,8 @@ public function addFieldValueFactorFunction( } /** - * @param float $weight the weight of the function - * @param AbstractQuery $filter a filter associated with this function + * @param float $weight the weight of the function + * @param AbstractQuery|null $filter a filter associated with this function * * @return $this */ @@ -197,10 +197,10 @@ public function addWeightFunction(float $weight, ?AbstractQuery $filter = null): /** * Add a random_score function to the query. * - * @param int $seed the seed value - * @param AbstractQuery $filter a filter associated with this function - * @param float $weight an optional boost value associated with this function - * @param string $field the field to be used for random number generation + * @param int $seed the seed value + * @param AbstractQuery|null $filter a filter associated with this function + * @param float|null $weight an optional boost value associated with this function + * @param string|null $field the field to be used for random number generation * * @return $this */ @@ -256,7 +256,7 @@ public function setBoostMode(string $mode = self::BOOST_MODE_MULTIPLY): self /** * If set, this query will return results in random order. * - * @param int $seed set a seed value to return results in the same random order for consistent pagination + * @param int|null $seed set a seed value to return results in the same random order for consistent pagination * * @return $this */ diff --git a/src/Query/Fuzzy.php b/src/Query/Fuzzy.php index 5bc418a4da..b0a5b108fb 100644 --- a/src/Query/Fuzzy.php +++ b/src/Query/Fuzzy.php @@ -16,7 +16,7 @@ class Fuzzy extends AbstractQuery /** * Construct a fuzzy query. * - * @param string $value String to search for + * @param string|null $value String to search for */ public function __construct(?string $fieldName = null, ?string $value = null) { diff --git a/src/Query/HasChild.php b/src/Query/HasChild.php index 23b6c281bb..93315732a7 100644 --- a/src/Query/HasChild.php +++ b/src/Query/HasChild.php @@ -17,7 +17,7 @@ class HasChild extends AbstractQuery * Construct HasChild Query. * * @param AbstractQuery|BaseQuery|string $query - * @param string $type Parent document type + * @param string|null $type Parent document type */ public function __construct($query, ?string $type = null) { @@ -40,7 +40,7 @@ public function setQuery($query): self /** * Set type of the parent document. * - * @param string $type Parent document type + * @param string|null $type Parent document type * * @return $this */ diff --git a/src/Query/MatchPhrase.php b/src/Query/MatchPhrase.php index fca62e6779..85c9236e24 100644 --- a/src/Query/MatchPhrase.php +++ b/src/Query/MatchPhrase.php @@ -13,8 +13,7 @@ class MatchPhrase extends AbstractQuery { /** - * @param string $field - * @param mixed $values + * @param mixed $values */ public function __construct(?string $field = null, $values = null) { diff --git a/src/Query/MatchQuery.php b/src/Query/MatchQuery.php index 84fb578caa..6bd85e4037 100644 --- a/src/Query/MatchQuery.php +++ b/src/Query/MatchQuery.php @@ -21,8 +21,7 @@ class MatchQuery extends AbstractQuery public const FUZZINESS_AUTO = 'AUTO'; /** - * @param string $field - * @param mixed $values + * @param mixed $values */ public function __construct(?string $field = null, $values = null) { diff --git a/src/Query/Range.php b/src/Query/Range.php index a36855723e..038451629b 100644 --- a/src/Query/Range.php +++ b/src/Query/Range.php @@ -14,8 +14,8 @@ class Range extends AbstractQuery /** * Constructor. * - * @param string $fieldName Field name - * @param array $args Field arguments + * @param string|null $fieldName Field name + * @param array $args Field arguments */ public function __construct(?string $fieldName = null, array $args = []) { diff --git a/src/Query/Regexp.php b/src/Query/Regexp.php index 1ae9f4ff9e..368f6235ec 100644 --- a/src/Query/Regexp.php +++ b/src/Query/Regexp.php @@ -14,9 +14,9 @@ class Regexp extends AbstractQuery /** * Construct regexp query. * - * @param string $key OPTIONAL Regexp key - * @param string $value OPTIONAL Regexp value - * @param float $boost OPTIONAL Boost value (default = 1) + * @param string $key OPTIONAL Regexp key + * @param string|null $value OPTIONAL Regexp value + * @param float $boost OPTIONAL Boost value (default = 1) */ public function __construct(string $key = '', ?string $value = null, float $boost = 1.0) { @@ -28,8 +28,6 @@ public function __construct(string $key = '', ?string $value = null, float $boos /** * Sets the query expression for a key with its boost value. * - * @param string $value - * * @return $this */ public function setValue(string $key, ?string $value = null, float $boost = 1.0) diff --git a/src/Query/SpanFirst.php b/src/Query/SpanFirst.php index 350b938897..cef8831a51 100644 --- a/src/Query/SpanFirst.php +++ b/src/Query/SpanFirst.php @@ -15,7 +15,6 @@ class SpanFirst extends AbstractSpanQuery { /** * @param AbstractQuery|array $match - * @param int $end */ public function __construct($match = null, ?int $end = null) { diff --git a/src/Query/SpanNot.php b/src/Query/SpanNot.php index 64a7a67dd0..2448e554a4 100644 --- a/src/Query/SpanNot.php +++ b/src/Query/SpanNot.php @@ -11,10 +11,6 @@ */ class SpanNot extends AbstractSpanQuery { - /** - * @param AbstractSpanQuery $include - * @param AbstractSpanQuery $exclude - */ public function __construct(?AbstractSpanQuery $include = null, ?AbstractSpanQuery $exclude = null) { if (null !== $include) { diff --git a/src/QueryBuilder/DSL/Aggregation.php b/src/QueryBuilder/DSL/Aggregation.php index 44df3e4f1a..0820de7bf5 100644 --- a/src/QueryBuilder/DSL/Aggregation.php +++ b/src/QueryBuilder/DSL/Aggregation.php @@ -167,8 +167,8 @@ public function value_count(string $name, string $field): ValueCount * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html * - * @param string $name the name of this aggregation - * @param string $field the field on which to perform this aggregation + * @param string $name the name of this aggregation + * @param string|null $field the field on which to perform this aggregation */ public function percentiles(string $name, ?string $field = null): Percentiles { @@ -180,8 +180,8 @@ public function percentiles(string $name, ?string $field = null): Percentiles * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-percentiles-bucket-aggregation.html * - * @param string $name the name of this aggregation - * @param string $bucketsPath the field on which to perform this aggregation + * @param string $name the name of this aggregation + * @param string|null $bucketsPath the field on which to perform this aggregation */ public function percentiles_bucket(string $name, ?string $bucketsPath = null): PercentilesBucket { @@ -267,8 +267,6 @@ public function global_agg(string $name): GlobalAggregation * filter aggregation. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html - * - * @param AbstractQuery $filter */ public function filter(string $name, ?AbstractQuery $filter = null): Filter { @@ -312,8 +310,8 @@ public function nested(string $name, string $path): Nested * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html * - * @param string $name The name of this aggregation - * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. + * @param string $name The name of this aggregation + * @param string|null $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. */ public function reverse_nested(string $name, ?string $path = null): ReverseNested { diff --git a/src/QueryBuilder/DSL/Query.php b/src/QueryBuilder/DSL/Query.php index 2b0681d60d..55a365884f 100644 --- a/src/QueryBuilder/DSL/Query.php +++ b/src/QueryBuilder/DSL/Query.php @@ -171,7 +171,7 @@ public function function_score(): FunctionScore * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html * - * @param string $value String to search for + * @param string|null $value String to search for */ public function fuzzy(?string $fieldName = null, ?string $value = null): Fuzzy { @@ -216,7 +216,7 @@ public function geo_polygon(string $key, array $points): GeoPolygon * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html * * @param AbstractQuery|BaseQuery|string $query - * @param string $type Parent document type + * @param string|null $type Parent document type */ public function has_child($query, ?string $type = null): HasChild { diff --git a/src/Suggest.php b/src/Suggest.php index d7576b60f7..6512a0c2d0 100644 --- a/src/Suggest.php +++ b/src/Suggest.php @@ -12,9 +12,6 @@ */ class Suggest extends Param { - /** - * @param AbstractSuggest $suggestion - */ public function __construct(?AbstractSuggest $suggestion = null) { if (null !== $suggestion) { diff --git a/src/Transport/AbstractTransport.php b/src/Transport/AbstractTransport.php index dcdbf3368c..b00163e762 100644 --- a/src/Transport/AbstractTransport.php +++ b/src/Transport/AbstractTransport.php @@ -62,7 +62,7 @@ abstract public function exec(Request $request, array $params): Response; * BOOL values true|false should be sanityzed and passed to Elasticsearch * as string. * - * @return mixed + * @return array */ public function sanityzeQueryStringBool(array $query) {