Skip to content

Commit 330e77e

Browse files
authored
Merge pull request #1666 from deguif/type-hint-switch-alias-processor-signatures
Add type-hints on signatures of alias-processor methods
2 parents 71ae73e + fa153c1 commit 330e77e

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

CHANGELOG-6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ in 6.0 versions.
1414
* Removed `FOS\ElasticaBundle\Exception\InvalidArgumentTypeException`.
1515
* **[BC break]** Changed signature of method `FOS\ElasticaBundle\Finder\FinderInterface::find()`.
1616
* **[BC break]** Changed signature of method `FOS\ElasticaBundle\HybridResult::getResult()`.
17+
* **[BC break]** Changed signature of method `FOS\ElasticaBundle\Index\AliasProcessor::switchIndexAlias()`.
1718
* **[BC break]** Changed signature of method `FOS\ElasticaBundle\Persister\ObjectPersisterInterface::handlesObject()`.
1819
* **[BC break]** Changed signature of method `FOS\ElasticaBundle\Provider\PagerProviderInterface::provide()`.
1920
* **[BC break]** Changed signature of methods `getPager`, `getOptions` and `getObjectPersister` from interface `FOS\ElasticaBundle\Persister\Event\PersistEvent`.

src/Index/AliasProcessor.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ public function setRootName(IndexConfig $indexConfig, Index $index)
3939
*
4040
* $force will delete an index encountered where an alias is expected.
4141
*
42-
* @param bool $force
43-
* @param bool $delete
44-
*
4542
* @throws AliasIsIndexException
4643
*/
47-
public function switchIndexAlias(IndexConfig $indexConfig, Index $index, $force = false, $delete = true)
44+
public function switchIndexAlias(IndexConfig $indexConfig, Index $index, bool $force = false, bool $delete = true)
4845
{
4946
$client = $index->getClient();
5047

@@ -85,14 +82,8 @@ public function switchIndexAlias(IndexConfig $indexConfig, Index $index, $force
8582

8683
/**
8784
* Builds an ElasticSearch request to rename or create an alias.
88-
*
89-
* @param string|null $aliasedIndex
90-
* @param string $aliasName
91-
* @param string $newIndexName
92-
*
93-
* @return array
9485
*/
95-
private function buildAliasUpdateRequest($aliasedIndex, $aliasName, $newIndexName)
86+
private function buildAliasUpdateRequest(?string $aliasedIndex, string $aliasName, string $newIndexName): array
9687
{
9788
$aliasUpdateRequest = ['actions' => []];
9889
if (null !== $aliasedIndex) {
@@ -112,10 +103,8 @@ private function buildAliasUpdateRequest($aliasedIndex, $aliasName, $newIndexNam
112103

113104
/**
114105
* Cleans up an index when we encounter a failure to rename the alias.
115-
*
116-
* @param string $indexName
117106
*/
118-
private function cleanupRenameFailure(Client $client, $indexName, \Exception $renameAliasException)
107+
private function cleanupRenameFailure(Client $client, string $indexName, \Exception $renameAliasException): void
119108
{
120109
$additionalError = '';
121110
try {
@@ -133,10 +122,8 @@ private function cleanupRenameFailure(Client $client, $indexName, \Exception $re
133122

134123
/**
135124
* Delete an index.
136-
*
137-
* @param string $indexName Index name to delete
138125
*/
139-
private function deleteIndex(Client $client, $indexName)
126+
private function deleteIndex(Client $client, string $indexName): void
140127
{
141128
try {
142129
$path = $indexName;
@@ -148,10 +135,8 @@ private function deleteIndex(Client $client, $indexName)
148135

149136
/**
150137
* Close an index.
151-
*
152-
* @param string $indexName
153138
*/
154-
private function closeIndex(Client $client, $indexName)
139+
private function closeIndex(Client $client, string $indexName): void
155140
{
156141
try {
157142
$path = $indexName.'/_close';
@@ -165,13 +150,9 @@ private function closeIndex(Client $client, $indexName)
165150
* Returns the name of a single index that an alias points to or throws
166151
* an exception if there is more than one.
167152
*
168-
* @param string $aliasName Alias name
169-
*
170-
* @return string|null
171-
*
172153
* @throws AliasIsIndexException
173154
*/
174-
private function getAliasedIndex(Client $client, $aliasName)
155+
private function getAliasedIndex(Client $client, string $aliasName): ?string
175156
{
176157
$aliasesInfo = $client->request('_aliases', 'GET')->getData();
177158
$aliasedIndexes = [];

0 commit comments

Comments
 (0)