Skip to content

Commit

Permalink
Use strict option for in_array() function (#1929)
Browse files Browse the repository at this point in the history
* Use strict option for in_array()

* Add changelog
  • Loading branch information
deguif authored Mar 22, 2021
1 parent cd4ec8d commit 545d5b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Backward Compatibility Breaks
### Added
### Changed
* Changed `Elastica\Status::indexExists()`, `Elastica\Status::aliasExists()` and `Elastica\Status::getIndicesWithAlias()` signatures [#1929](https://github.com/ruflin/Elastica/pull/1929)
* Replaced `call_user_func()` and `call_user_func_array()` by direct calls [#1923](https://github.com/ruflin/Elastica/pull/1923)
* Replaced legacy constant `CURLINFO_HTTP_CODE` by `CURLINFO_RESPONSE_CODE` [#1931](https://github.com/ruflin/Elastica/pull/1931)
* Updated `php-cs-fixer` to `2.18.3` [#1915](https://github.com/ruflin/Elastica/pull/1915)
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractUpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function getRefresh()
{
$refresh = $this->getParam('refresh');

return \in_array($refresh, [Reindex::REFRESH_TRUE, Reindex::REFRESH_FALSE])
return \in_array($refresh, [Reindex::REFRESH_TRUE, Reindex::REFRESH_FALSE], true)
? Reindex::REFRESH_TRUE === $refresh
: $refresh;
}
Expand Down
16 changes: 5 additions & 11 deletions src/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,29 @@ public function getIndexNames()
/**
* Checks if the given index exists.
*
* @param string $name Index name to check
*
* @return bool True if index exists
*/
public function indexExists($name)
public function indexExists(string $name)
{
return \in_array($name, $this->getIndexNames());
return \in_array($name, $this->getIndexNames(), true);
}

/**
* Checks if the given alias exists.
*
* @param string $name Alias name
*
* @return bool True if alias exists
*/
public function aliasExists($name)
public function aliasExists(string $name)
{
return \count($this->getIndicesWithAlias($name)) > 0;
}

/**
* Returns an array with all indices that the given alias name points to.
*
* @param string $alias Alias name
*
* @return array|Index[] List of Elastica\Index
* @return Index[]
*/
public function getIndicesWithAlias($alias)
public function getIndicesWithAlias(string $alias)
{
// TODO: Use only GetAlias when dropping support for elasticsearch/elasticsearch 7.x
$endpoint = \class_exists(GetAlias::class) ? new GetAlias() : new Get();
Expand Down

0 comments on commit 545d5b4

Please sign in to comment.