Skip to content

Commit

Permalink
Fix PHPStorm findings (#2087)
Browse files Browse the repository at this point in the history
* Fix case mismatch method names

* Update PHPDoc to match method signature

* Fix some PHPDoc
  • Loading branch information
franmomu authored Jun 24, 2022
1 parent 1e74607 commit a0a2dc2
Show file tree
Hide file tree
Showing 26 changed files with 63 additions and 79 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Aggregation/GeoDistance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions src/Aggregation/IpRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions src/Aggregation/Percentiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Aggregation/ReverseNested.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bulk/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Action
protected $_metadata = [];

/**
* @var array
* @var array|string
*/
protected $_source = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -387,7 +387,7 @@ public function hasConnection()
}

/**
* @throws \Elastica\Exception\ClientException
* @throws ClientException
*
* @return Connection
*/
Expand Down
4 changes: 1 addition & 3 deletions src/Exception/Connection/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 3 additions & 4 deletions src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Index/Recovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function refresh(): self
}

/**
* @return mixed
* @return array
*/
protected function getRecoveryData()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
42 changes: 21 additions & 21 deletions src/Query/FunctionScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Fuzzy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Query/HasChild.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Query/MatchPhrase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Query/MatchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Query/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [])
{
Expand Down
8 changes: 3 additions & 5 deletions src/Query/Regexp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/Query/SpanFirst.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SpanFirst extends AbstractSpanQuery
{
/**
* @param AbstractQuery|array $match
* @param int $end
*/
public function __construct($match = null, ?int $end = null)
{
Expand Down
4 changes: 0 additions & 4 deletions src/Query/SpanNot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit a0a2dc2

Please sign in to comment.