Skip to content

Commit

Permalink
Relax Setting::setMergePolicy value to allow int
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jun 22, 2022
1 parent ff1a6e0 commit 19997c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/ruflin/Elastica/compare/7.1.5...master)
### Backward Compatibility Breaks
* Changed `Settings::setMergePolicy` signature to allow to pass `int` and `string` as argument 2, if you are overriding this method you must update the signature removing the `string` type-hint.
### 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)
Expand Down
7 changes: 4 additions & 3 deletions src/Index/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,12 @@ public function getRefreshInterval(): string
*
* To have this changes made the index has to be closed and reopened
*
* @param string $key Merge policy key (for ex. expunge_deletes_allowed)
* @param string $key Merge policy key (for ex. expunge_deletes_allowed)
* @param int|string $value
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html
*/
public function setMergePolicy(string $key, string $value): Response
public function setMergePolicy(string $key, $value): Response
{
$this->_index->close();
$response = $this->set(['merge.policy.'.$key => $value]);
Expand All @@ -277,7 +278,7 @@ public function setMergePolicy(string $key, string $value): Response
*
* @param string $key Merge policy key (for ex. expunge_deletes_allowed)
*
* @return string Refresh interval
* @return int|string
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/Index/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ public function testSetMergePolicy(): void
$settings = $index->getSettings();

$settings->setMergePolicy('expunge_deletes_allowed', 15);
$this->assertEquals(15, $settings->getMergePolicy('expunge_deletes_allowed'));
$this->assertSame(15, $settings->getMergePolicy('expunge_deletes_allowed'));

$settings->setMergePolicy('expunge_deletes_allowed', 10);
$this->assertEquals(10, $settings->getMergePolicy('expunge_deletes_allowed'));
$this->assertSame(10, $settings->getMergePolicy('expunge_deletes_allowed'));

$index->delete();
}
Expand Down

0 comments on commit 19997c2

Please sign in to comment.