Skip to content

Commit a7beea1

Browse files
fsamapoorcome-nc
andcommitted
Refactors lib/private/FullTextSearch.
Mainly using PHP8's constructor property promotion. Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com> Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
1 parent d439317 commit a7beea1

File tree

6 files changed

+80
-499
lines changed

6 files changed

+80
-499
lines changed

lib/private/FullTextSearch/FullTextSearchManager.php

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,35 @@
3939
* @package OC\FullTextSearch
4040
*/
4141
class FullTextSearchManager implements IFullTextSearchManager {
42-
/** @var IProviderService */
43-
private $providerService;
42+
private ?IProviderService $providerService;
4443

45-
/** @var IIndexService */
46-
private $indexService;
47-
48-
/** @var ISearchService */
49-
private $searchService;
44+
private ?IIndexService $indexService;
5045

46+
private ?ISearchService $searchService;
5147

5248
/**
5349
* @since 15.0.0
54-
*
55-
* @param IProviderService $providerService
5650
*/
57-
public function registerProviderService(IProviderService $providerService) {
51+
public function registerProviderService(IProviderService $providerService): void {
5852
$this->providerService = $providerService;
5953
}
6054

6155
/**
6256
* @since 15.0.0
63-
*
64-
* @param IIndexService $indexService
6557
*/
66-
public function registerIndexService(IIndexService $indexService) {
58+
public function registerIndexService(IIndexService $indexService): void {
6759
$this->indexService = $indexService;
6860
}
6961

7062
/**
7163
* @since 15.0.0
72-
*
73-
* @param ISearchService $searchService
7464
*/
75-
public function registerSearchService(ISearchService $searchService) {
65+
public function registerSearchService(ISearchService $searchService): void {
7666
$this->searchService = $searchService;
7767
}
7868

7969
/**
8070
* @since 16.0.0
81-
*
82-
* @return bool
8371
*/
8472
public function isAvailable(): bool {
8573
if ($this->indexService === null ||
@@ -93,7 +81,6 @@ public function isAvailable(): bool {
9381

9482

9583
/**
96-
* @return IProviderService
9784
* @throws FullTextSearchAppNotAvailableException
9885
*/
9986
private function getProviderService(): IProviderService {
@@ -106,7 +93,6 @@ private function getProviderService(): IProviderService {
10693

10794

10895
/**
109-
* @return IIndexService
11096
* @throws FullTextSearchAppNotAvailableException
11197
*/
11298
private function getIndexService(): IIndexService {
@@ -119,7 +105,6 @@ private function getIndexService(): IIndexService {
119105

120106

121107
/**
122-
* @return ISearchService
123108
* @throws FullTextSearchAppNotAvailableException
124109
*/
125110
private function getSearchService(): ISearchService {
@@ -134,15 +119,12 @@ private function getSearchService(): ISearchService {
134119
/**
135120
* @throws FullTextSearchAppNotAvailableException
136121
*/
137-
public function addJavascriptAPI() {
122+
public function addJavascriptAPI(): void {
138123
$this->getProviderService()->addJavascriptAPI();
139124
}
140125

141126

142127
/**
143-
* @param string $providerId
144-
*
145-
* @return bool
146128
* @throws FullTextSearchAppNotAvailableException
147129
*/
148130
public function isProviderIndexed(string $providerId): bool {
@@ -151,56 +133,52 @@ public function isProviderIndexed(string $providerId): bool {
151133

152134

153135
/**
154-
* @param string $providerId
155-
* @param string $documentId
156-
* @return IIndex
157136
* @throws FullTextSearchAppNotAvailableException
158137
*/
159138
public function getIndex(string $providerId, string $documentId): IIndex {
160139
return $this->getIndexService()->getIndex($providerId, $documentId);
161140
}
162141

163142
/**
164-
* @param string $providerId
165-
* @param string $documentId
166-
* @param string $userId
167-
* @param int $status
168-
*
169143
* @see IIndex for available value for $status.
170144
*
171-
* @return IIndex
172145
* @throws FullTextSearchAppNotAvailableException
173146
*/
174-
public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex {
147+
public function createIndex(
148+
string $providerId,
149+
string $documentId,
150+
string $userId,
151+
int $status = 0,
152+
): IIndex {
175153
return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status);
176154
}
177155

178156

179157
/**
180-
* @param string $providerId
181-
* @param string $documentId
182-
* @param int $status
183-
* @param bool $reset
184-
*
185158
* @see IIndex for available value for $status.
186159
*
187160
* @throws FullTextSearchAppNotAvailableException
188161
*/
189-
public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) {
162+
public function updateIndexStatus(
163+
string $providerId,
164+
string $documentId,
165+
int $status,
166+
bool $reset = false,
167+
): void {
190168
$this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset);
191169
}
192170

193171
/**
194-
* @param string $providerId
195-
* @param array $documentIds
196-
* @param int $status
197-
* @param bool $reset
198-
*
199172
* @see IIndex for available value for $status.
200173
*
201174
* @throws FullTextSearchAppNotAvailableException
202175
*/
203-
public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) {
176+
public function updateIndexesStatus(
177+
string $providerId,
178+
array $documentIds,
179+
int $status,
180+
bool $reset = false,
181+
): void {
204182
$this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset);
205183
}
206184

@@ -210,15 +188,12 @@ public function updateIndexesStatus(string $providerId, array $documentIds, int
210188
*
211189
* @throws FullTextSearchAppNotAvailableException
212190
*/
213-
public function updateIndexes(array $indexes) {
191+
public function updateIndexes(array $indexes): void {
214192
$this->getIndexService()->updateIndexes($indexes);
215193
}
216194

217195

218196
/**
219-
* @param array $request
220-
* @param string $userId
221-
*
222197
* @return ISearchResult[]
223198
* @throws FullTextSearchAppNotAvailableException
224199
*/

0 commit comments

Comments
 (0)