Skip to content

Commit 629e918

Browse files
author
Faraz Samapoor
committed
Refactors lib/private/FullTextSearch.
Mainly using PHP8's constructor property promotion. Signed-off-by: Faraz Samapoor <[email protected]>
1 parent 2de859d commit 629e918

File tree

6 files changed

+88
-501
lines changed

6 files changed

+88
-501
lines changed

lib/private/FullTextSearch/FullTextSearchManager.php

Lines changed: 35 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -39,52 +39,46 @@
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 {
85-
if ($this->indexService === null ||
86-
$this->providerService === null ||
87-
$this->searchService === null) {
73+
if ($this->indexService === null) {
74+
return false;
75+
}
76+
77+
if ($this->providerService === null) {
78+
return false;
79+
}
80+
81+
if ($this->searchService === null) {
8882
return false;
8983
}
9084

@@ -93,7 +87,6 @@ public function isAvailable(): bool {
9387

9488

9589
/**
96-
* @return IProviderService
9790
* @throws FullTextSearchAppNotAvailableException
9891
*/
9992
private function getProviderService(): IProviderService {
@@ -106,7 +99,6 @@ private function getProviderService(): IProviderService {
10699

107100

108101
/**
109-
* @return IIndexService
110102
* @throws FullTextSearchAppNotAvailableException
111103
*/
112104
private function getIndexService(): IIndexService {
@@ -119,7 +111,6 @@ private function getIndexService(): IIndexService {
119111

120112

121113
/**
122-
* @return ISearchService
123114
* @throws FullTextSearchAppNotAvailableException
124115
*/
125116
private function getSearchService(): ISearchService {
@@ -134,15 +125,12 @@ private function getSearchService(): ISearchService {
134125
/**
135126
* @throws FullTextSearchAppNotAvailableException
136127
*/
137-
public function addJavascriptAPI() {
128+
public function addJavascriptAPI(): void {
138129
$this->getProviderService()->addJavascriptAPI();
139130
}
140131

141132

142133
/**
143-
* @param string $providerId
144-
*
145-
* @return bool
146134
* @throws FullTextSearchAppNotAvailableException
147135
*/
148136
public function isProviderIndexed(string $providerId): bool {
@@ -151,56 +139,52 @@ public function isProviderIndexed(string $providerId): bool {
151139

152140

153141
/**
154-
* @param string $providerId
155-
* @param string $documentId
156-
* @return IIndex
157142
* @throws FullTextSearchAppNotAvailableException
158143
*/
159144
public function getIndex(string $providerId, string $documentId): IIndex {
160145
return $this->getIndexService()->getIndex($providerId, $documentId);
161146
}
162147

163148
/**
164-
* @param string $providerId
165-
* @param string $documentId
166-
* @param string $userId
167-
* @param int $status
168-
*
169149
* @see IIndex for available value for $status.
170150
*
171-
* @return IIndex
172151
* @throws FullTextSearchAppNotAvailableException
173152
*/
174-
public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex {
153+
public function createIndex(
154+
string $providerId,
155+
string $documentId,
156+
string $userId,
157+
int $status = 0,
158+
): IIndex {
175159
return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status);
176160
}
177161

178162

179163
/**
180-
* @param string $providerId
181-
* @param string $documentId
182-
* @param int $status
183-
* @param bool $reset
184-
*
185164
* @see IIndex for available value for $status.
186165
*
187166
* @throws FullTextSearchAppNotAvailableException
188167
*/
189-
public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) {
168+
public function updateIndexStatus(
169+
string $providerId,
170+
string $documentId,
171+
int $status,
172+
bool $reset = false,
173+
): void {
190174
$this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset);
191175
}
192176

193177
/**
194-
* @param string $providerId
195-
* @param array $documentIds
196-
* @param int $status
197-
* @param bool $reset
198-
*
199178
* @see IIndex for available value for $status.
200179
*
201180
* @throws FullTextSearchAppNotAvailableException
202181
*/
203-
public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) {
182+
public function updateIndexesStatus(
183+
string $providerId,
184+
array $documentIds,
185+
int $status,
186+
bool $reset = false,
187+
): void {
204188
$this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset);
205189
}
206190

@@ -210,15 +194,12 @@ public function updateIndexesStatus(string $providerId, array $documentIds, int
210194
*
211195
* @throws FullTextSearchAppNotAvailableException
212196
*/
213-
public function updateIndexes(array $indexes) {
197+
public function updateIndexes(array $indexes): void {
214198
$this->getIndexService()->updateIndexes($indexes);
215199
}
216200

217201

218202
/**
219-
* @param array $request
220-
* @param string $userId
221-
*
222203
* @return ISearchResult[]
223204
* @throws FullTextSearchAppNotAvailableException
224205
*/

0 commit comments

Comments
 (0)