1212 * @author Roeland Jago Douma <roeland@famdouma.nl>
1313 * @author sualko <klaus@jsxc.org>
1414 * @author Carl Schwan <carl@carlschwan.eu>
15+ * @author Kate Döen <kate.doeen@nextcloud.com>
1516 *
1617 * @license GNU AGPL version 3 or any later version
1718 *
@@ -90,17 +91,14 @@ public function __construct(
9091 $ this ->subAdmin = $ subAdmin ;
9192 }
9293
93- /** @var array */
94+ /** @var array<'admin'|'personal', list<class-string<IIconSection>>> */
9495 protected $ sectionClasses = [];
9596
96- /** @var array */
97+ /** @var array<'admin'|'personal', array<string, IIconSection>> */
9798 protected $ sections = [];
9899
99100 /**
100- * @param string $type 'admin' or 'personal'
101- * @param string $section Class must implement OCP\Settings\IIconSection
102- *
103- * @return void
101+ * @inheritdoc
104102 */
105103 public function registerSection (string $ type , string $ section ) {
106104 if (!isset ($ this ->sectionClasses [$ type ])) {
@@ -111,7 +109,7 @@ public function registerSection(string $type, string $section) {
111109 }
112110
113111 /**
114- * @param string $type 'admin' or 'personal'
112+ * @psalm- param 'admin'| 'personal' $type
115113 *
116114 * @return IIconSection[]
117115 */
@@ -149,6 +147,9 @@ protected function getSections(string $type): array {
149147 return $ this ->sections [$ type ];
150148 }
151149
150+ /**
151+ * @inheritdoc
152+ */
152153 public function getSection (string $ type , string $ sectionId ): ?IIconSection {
153154 if (isset ($ this ->sections [$ type ]) && isset ($ this ->sections [$ type ][$ sectionId ])) {
154155 return $ this ->sections [$ type ][$ sectionId ];
@@ -163,27 +164,23 @@ protected function isKnownDuplicateSectionId(string $sectionID): bool {
163164 ], true );
164165 }
165166
166- /** @var array */
167+ /** @var array<class-string<ISettings>, 'admin'|'personal'> */
167168 protected $ settingClasses = [];
168169
169- /** @var array */
170+ /** @var array<'admin'|'personal', array<string, list<ISettings>>> */
170171 protected $ settings = [];
171172
172173 /**
173- * @psam-param 'admin'|'personal' $type The type of the setting.
174- * @param string $setting Class must implement OCP\Settings\ISettings
175- * @param bool $allowedDelegation
176- *
177- * @return void
174+ * @inheritdoc
178175 */
179176 public function registerSetting (string $ type , string $ setting ) {
180177 $ this ->settingClasses [$ setting ] = $ type ;
181178 }
182179
183180 /**
184- * @param string $type 'admin' or 'personal'
181+ * @psalm- param 'admin'| 'personal' $type The type of the setting.
185182 * @param string $section
186- * @param Closure $filter optional filter to apply on all loaded ISettings
183+ * @param ? Closure $filter optional filter to apply on all loaded ISettings
187184 *
188185 * @return ISettings[]
189186 */
@@ -252,7 +249,7 @@ public function getAdminSections(): array {
252249
253250 ksort ($ sections );
254251
255- return $ sections ;
252+ return array_values ( $ sections) ;
256253 }
257254
258255 /**
@@ -277,7 +274,7 @@ public function getAdminSettings($section, bool $subAdminOnly = false): array {
277274 }
278275
279276 ksort ($ settings );
280- return $ settings ;
277+ return array_values ( $ settings) ;
281278 }
282279
283280 /**
@@ -309,7 +306,7 @@ public function getPersonalSections(): array {
309306
310307 ksort ($ sections );
311308
312- return $ sections ;
309+ return array_values ( $ sections) ;
313310 }
314311
315312 /**
@@ -341,9 +338,12 @@ public function getPersonalSettings($section): array {
341338 }
342339
343340 ksort ($ settings );
344- return $ settings ;
341+ return array_values ( $ settings) ;
345342 }
346343
344+ /**
345+ * @inheritdoc
346+ */
347347 public function getAllowedAdminSettings (string $ section , IUser $ user ): array {
348348 $ isAdmin = $ this ->groupManager ->isAdmin ($ user ->getUID ());
349349 if ($ isAdmin ) {
@@ -372,9 +372,12 @@ public function getAllowedAdminSettings(string $section, IUser $user): array {
372372 }
373373
374374 ksort ($ settings );
375- return $ settings ;
375+ return array_values ( $ settings) ;
376376 }
377377
378+ /**
379+ * @inheritdoc
380+ */
378381 public function getAllAllowedAdminSettings (IUser $ user ): array {
379382 $ this ->getSettings ('admin ' , '' ); // Make sure all the settings are loaded
380383 $ settings = [];
0 commit comments