Skip to content

Commit 05dd6d9

Browse files
come-ncAndyScherzinger
authored andcommitted
fix: Add missing @throws annotations in UserConfig
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 8caeb11 commit 05dd6d9

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

lib/private/Config/UserConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,7 @@ private function isFlagged(int $needle, int $flags): bool {
17081708
* @param bool $allowEmptyUser
17091709
* @param bool $allowEmptyApp $app can be empty string
17101710
* @param ValueType|null $valueType assert value type is only one type
1711+
* @throws InvalidArgumentException if userId, app, or prefKey is invalid (too long, or empty string)
17111712
*/
17121713
private function assertParams(
17131714
string $userId = '',

lib/public/Config/IUserConfig.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ interface IUserConfig {
4848
* @param string $appId optional id of app
4949
*
5050
* @return list<string> list of userIds
51+
* @throws \InvalidArgumentException if $appId is invalid (too long)
5152
*
5253
* @since 32.0.0
5354
*/
@@ -62,6 +63,7 @@ public function getUserIds(string $appId = ''): array;
6263
* @param string $userId id of the user
6364
*
6465
* @return list<string> list of app ids
66+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
6567
*
6668
* @since 32.0.0
6769
*/
@@ -77,6 +79,7 @@ public function getApps(string $userId): array;
7779
* @param string $app id of the app
7880
*
7981
* @return list<string> list of stored config keys
82+
* @throws \InvalidArgumentException if $userId or $app is invalid (too long, or empty string)
8083
*
8184
* @since 32.0.0
8285
*/
@@ -91,6 +94,7 @@ public function getKeys(string $userId, string $app): array;
9194
* @param bool $lazy search within lazy loaded config
9295
*
9396
* @return bool TRUE if key exists
97+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
9498
*
9599
* @since 32.0.0
96100
*/
@@ -106,6 +110,7 @@ public function hasKey(string $userId, string $app, string $key, ?bool $lazy = f
106110
*
107111
* @return bool TRUE if value is sensitive
108112
* @throws UnknownKeyException if config key is not known
113+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
109114
*
110115
* @since 32.0.0
111116
*/
@@ -126,6 +131,7 @@ public function isSensitive(string $userId, string $app, string $key, ?bool $laz
126131
*
127132
* @return bool TRUE if value is sensitive
128133
* @throws UnknownKeyException if config key is not known
134+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
129135
*
130136
* @since 32.0.0
131137
*/
@@ -142,6 +148,7 @@ public function isIndexed(string $userId, string $app, string $key, ?bool $lazy
142148
*
143149
* @return bool TRUE if config is lazy loaded
144150
* @throws UnknownKeyException if config key is not known
151+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
145152
* @see IUserConfig for details about lazy loading
146153
*
147154
* @since 32.0.0
@@ -160,6 +167,7 @@ public function isLazy(string $userId, string $app, string $key): bool;
160167
* @param bool $filtered filter sensitive config values
161168
*
162169
* @return array<string, string|int|float|bool|array> [key => value]
170+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
163171
*
164172
* @since 32.0.0
165173
*/
@@ -175,6 +183,7 @@ public function getValues(string $userId, string $app, string $prefix = '', bool
175183
* @param bool $filtered filter sensitive config values
176184
*
177185
* @return array<string, string|int|float|bool|array> [key => value]
186+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
178187
*
179188
* @since 32.0.0
180189
*/
@@ -190,6 +199,7 @@ public function getAllValues(string $userId, bool $filtered = false): array;
190199
* @param ValueType|null $typedAs enforce type for the returned values
191200
*
192201
* @return array<string, string|int|float|bool|array> [appId => value]
202+
* @throws \InvalidArgumentException if $userId or $key is invalid (too long, or empty string)
193203
*
194204
* @since 32.0.0
195205
*/
@@ -207,6 +217,7 @@ public function getValuesByApps(string $userId, string $key, bool $lazy = false,
207217
* @param array|null $userIds limit the search to a list of user ids
208218
*
209219
* @return array<string, string|int|float|bool|array> [userId => value]
220+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
210221
*
211222
* @since 32.0.0
212223
*/
@@ -224,6 +235,7 @@ public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs =
224235
* @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string
225236
*
226237
* @return Generator<string>
238+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
227239
*
228240
* @since 32.0.0
229241
*/
@@ -240,6 +252,7 @@ public function searchUsersByValueString(string $app, string $key, string $value
240252
* @param int $value config value
241253
*
242254
* @return Generator<string>
255+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
243256
*
244257
* @since 32.0.0
245258
*/
@@ -256,6 +269,7 @@ public function searchUsersByValueInt(string $app, string $key, int $value): Gen
256269
* @param array $values list of possible config values
257270
*
258271
* @return Generator<string>
272+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
259273
*
260274
* @since 32.0.0
261275
*/
@@ -272,6 +286,7 @@ public function searchUsersByValues(string $app, string $key, array $values): Ge
272286
* @param bool $value config value
273287
*
274288
* @return Generator<string>
289+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
275290
*
276291
* @since 32.0.0
277292
*/
@@ -289,6 +304,7 @@ public function searchUsersByValueBool(string $app, string $key, bool $value): G
289304
* @param bool $lazy search within lazy loaded config
290305
*
291306
* @return string stored config value or $default if not set in database
307+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
292308
*
293309
* @since 32.0.0
294310
*
@@ -312,6 +328,7 @@ public function getValueString(string $userId, string $app, string $key, string
312328
* @param bool $lazy search within lazy loaded config
313329
*
314330
* @return int stored config value or $default if not set in database
331+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
315332
*
316333
* @since 32.0.0
317334
*
@@ -335,6 +352,7 @@ public function getValueInt(string $userId, string $app, string $key, int $defau
335352
* @param bool $lazy search within lazy loaded config
336353
*
337354
* @return float stored config value or $default if not set in database
355+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
338356
*
339357
* @since 32.0.0
340358
*
@@ -358,6 +376,7 @@ public function getValueFloat(string $userId, string $app, string $key, float $d
358376
* @param bool $lazy search within lazy loaded config
359377
*
360378
* @return bool stored config value or $default if not set in database
379+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
361380
*
362381
* @since 32.0.0
363382
*
@@ -381,6 +400,7 @@ public function getValueBool(string $userId, string $app, string $key, bool $def
381400
* @param bool $lazy search within lazy loaded config
382401
*
383402
* @return array stored config value or $default if not set in database
403+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
384404
*
385405
* @since 32.0.0
386406
*
@@ -406,6 +426,7 @@ public function getValueArray(string $userId, string $app, string $key, array $d
406426
* @return ValueType type of the value
407427
* @throws UnknownKeyException if config key is not known
408428
* @throws IncorrectTypeException if config value type is not known
429+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
409430
*
410431
* @since 32.0.0
411432
*/
@@ -425,6 +446,7 @@ public function getValueType(string $userId, string $app, string $key, ?bool $la
425446
* @return int a bitflag in relation to the config value
426447
* @throws UnknownKeyException if config key is not known
427448
* @throws IncorrectTypeException if config value type is not known
449+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
428450
*
429451
* @since 32.0.0
430452
*/
@@ -446,6 +468,7 @@ public function getValueFlags(string $userId, string $app, string $key, bool $la
446468
* @param bool $lazy set config as lazy loaded
447469
*
448470
* @return bool TRUE if value was different, therefor updated in database
471+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
449472
*
450473
* @since 32.0.0
451474
*
@@ -478,6 +501,7 @@ public function setValueString(string $userId, string $app, string $key, string
478501
* @param bool $lazy set config as lazy loaded
479502
*
480503
* @return bool TRUE if value was different, therefor updated in database
504+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
481505
*
482506
* @since 32.0.0
483507
*
@@ -505,6 +529,7 @@ public function setValueInt(string $userId, string $app, string $key, int $value
505529
* @param bool $lazy set config as lazy loaded
506530
*
507531
* @return bool TRUE if value was different, therefor updated in database
532+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
508533
*
509534
* @since 32.0.0
510535
*
@@ -531,6 +556,7 @@ public function setValueFloat(string $userId, string $app, string $key, float $v
531556
* @param bool $lazy set config as lazy loaded
532557
*
533558
* @return bool TRUE if value was different, therefor updated in database
559+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
534560
*
535561
* @since 32.0.0
536562
*
@@ -558,6 +584,7 @@ public function setValueBool(string $userId, string $app, string $key, bool $val
558584
* @param bool $lazy set config as lazy loaded
559585
*
560586
* @return bool TRUE if value was different, therefor updated in database
587+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
561588
*
562589
* @since 32.0.0
563590
*
@@ -580,6 +607,7 @@ public function setValueArray(string $userId, string $app, string $key, array $v
580607
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
581608
*
582609
* @return bool TRUE if database update were necessary
610+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
583611
*
584612
* @since 32.0.0
585613
*/
@@ -593,6 +621,7 @@ public function updateSensitive(string $userId, string $app, string $key, bool $
593621
* @param string $app id of the app
594622
* @param string $key config key
595623
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
624+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
596625
*
597626
* @since 32.0.0
598627
*/
@@ -610,6 +639,7 @@ public function updateGlobalSensitive(string $app, string $key, bool $sensitive)
610639
* @param bool $indexed TRUE to set as indexed, FALSE to unset
611640
*
612641
* @return bool TRUE if database update were necessary
642+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
613643
*
614644
* @since 32.0.0
615645
*/
@@ -623,6 +653,7 @@ public function updateIndexed(string $userId, string $app, string $key, bool $in
623653
* @param string $app id of the app
624654
* @param string $key config key
625655
* @param bool $indexed TRUE to set as indexed, FALSE to unset
656+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
626657
*
627658
* @since 32.0.0
628659
*/
@@ -637,6 +668,7 @@ public function updateGlobalIndexed(string $app, string $key, bool $indexed): vo
637668
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
638669
*
639670
* @return bool TRUE if database update was necessary
671+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
640672
*
641673
* @since 32.0.0
642674
*/
@@ -650,6 +682,7 @@ public function updateLazy(string $userId, string $app, string $key, bool $lazy)
650682
* @param string $app id of the app
651683
* @param string $key config key
652684
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
685+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
653686
*
654687
* @since 32.0.0
655688
*/
@@ -676,6 +709,7 @@ public function updateGlobalLazy(string $app, string $key, bool $lazy): void;
676709
*
677710
* @return array
678711
* @throws UnknownKeyException if config key is not known in database
712+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
679713
*
680714
* @since 32.0.0
681715
*/
@@ -687,6 +721,7 @@ public function getDetails(string $userId, string $app, string $key): array;
687721
* @param string $userId id of the user
688722
* @param string $app id of the app
689723
* @param string $key config key
724+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
690725
*
691726
* @since 32.0.0
692727
*/
@@ -697,6 +732,7 @@ public function deleteUserConfig(string $userId, string $app, string $key): void
697732
*
698733
* @param string $app id of the app
699734
* @param string $key config key
735+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
700736
*
701737
* @since 32.0.0
702738
*/
@@ -706,6 +742,7 @@ public function deleteKey(string $app, string $key): void;
706742
* delete all config keys linked to an app
707743
*
708744
* @param string $app id of the app
745+
* @throws \InvalidArgumentException if $app is invalid (too long, or empty string)
709746
*
710747
* @since 32.0.0
711748
*/
@@ -715,6 +752,7 @@ public function deleteApp(string $app): void;
715752
* delete all config keys linked to a user
716753
*
717754
* @param string $userId id of the user
755+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
718756
*
719757
* @since 32.0.0
720758
*/
@@ -727,6 +765,7 @@ public function deleteAllUserConfig(string $userId): void;
727765
*
728766
* @param string $userId id of the user
729767
* @param bool $reload set to TRUE to refill cache instantly after clearing it
768+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
730769
*
731770
* @since 32.0.0
732771
*/

0 commit comments

Comments
 (0)