Skip to content

Commit 56800a7

Browse files
come-ncbackportbot[bot]
authored andcommitted
fix: Add missing @throws annotations in UserConfig
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 0e79f6e commit 56800a7

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

lib/private/Config/UserConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,7 @@ private function isFlagged(int $needle, int $flags): bool {
17151715
* @param bool $allowEmptyUser
17161716
* @param bool $allowEmptyApp $app can be empty string
17171717
* @param ValueType|null $valueType assert value type is only one type
1718+
* @throws InvalidArgumentException if userId, app, or prefKey is invalid (too long, or empty string)
17181719
*/
17191720
private function assertParams(
17201721
string $userId = '',

lib/public/Config/IUserConfig.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ interface IUserConfig {
5252
* @param string $appId optional id of app
5353
*
5454
* @return list<string> list of userIds
55+
* @throws \InvalidArgumentException if $appId is invalid (too long)
5556
*
5657
* @since 32.0.0
5758
*/
@@ -66,6 +67,7 @@ public function getUserIds(string $appId = ''): array;
6667
* @param string $userId id of the user
6768
*
6869
* @return list<string> list of app ids
70+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
6971
*
7072
* @since 32.0.0
7173
*/
@@ -81,6 +83,7 @@ public function getApps(string $userId): array;
8183
* @param string $app id of the app
8284
*
8385
* @return list<string> list of stored config keys
86+
* @throws \InvalidArgumentException if $userId or $app is invalid (too long, or empty string)
8487
*
8588
* @since 32.0.0
8689
*/
@@ -95,6 +98,7 @@ public function getKeys(string $userId, string $app): array;
9598
* @param bool $lazy search within lazy loaded config
9699
*
97100
* @return bool TRUE if key exists
101+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
98102
*
99103
* @since 32.0.0
100104
*/
@@ -110,6 +114,7 @@ public function hasKey(string $userId, string $app, string $key, ?bool $lazy = f
110114
*
111115
* @return bool TRUE if value is sensitive
112116
* @throws UnknownKeyException if config key is not known
117+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
113118
*
114119
* @since 32.0.0
115120
*/
@@ -130,6 +135,7 @@ public function isSensitive(string $userId, string $app, string $key, ?bool $laz
130135
*
131136
* @return bool TRUE if value is sensitive
132137
* @throws UnknownKeyException if config key is not known
138+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
133139
*
134140
* @since 32.0.0
135141
*/
@@ -146,6 +152,7 @@ public function isIndexed(string $userId, string $app, string $key, ?bool $lazy
146152
*
147153
* @return bool TRUE if config is lazy loaded
148154
* @throws UnknownKeyException if config key is not known
155+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
149156
* @see IUserConfig for details about lazy loading
150157
*
151158
* @since 32.0.0
@@ -164,6 +171,7 @@ public function isLazy(string $userId, string $app, string $key): bool;
164171
* @param bool $filtered filter sensitive config values
165172
*
166173
* @return array<string, string|int|float|bool|array> [key => value]
174+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
167175
*
168176
* @since 32.0.0
169177
*/
@@ -179,6 +187,7 @@ public function getValues(string $userId, string $app, string $prefix = '', bool
179187
* @param bool $filtered filter sensitive config values
180188
*
181189
* @return array<string, string|int|float|bool|array> [key => value]
190+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
182191
*
183192
* @since 32.0.0
184193
*/
@@ -194,6 +203,7 @@ public function getAllValues(string $userId, bool $filtered = false): array;
194203
* @param ValueType|null $typedAs enforce type for the returned values
195204
*
196205
* @return array<string, string|int|float|bool|array> [appId => value]
206+
* @throws \InvalidArgumentException if $userId or $key is invalid (too long, or empty string)
197207
*
198208
* @since 32.0.0
199209
*/
@@ -211,6 +221,7 @@ public function getValuesByApps(string $userId, string $key, bool $lazy = false,
211221
* @param array|null $userIds limit the search to a list of user ids
212222
*
213223
* @return array<string, string|int|float|bool|array> [userId => value]
224+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
214225
*
215226
* @since 32.0.0
216227
*/
@@ -228,6 +239,7 @@ public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs =
228239
* @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string
229240
*
230241
* @return Generator<string>
242+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
231243
*
232244
* @since 32.0.0
233245
*/
@@ -244,6 +256,7 @@ public function searchUsersByValueString(string $app, string $key, string $value
244256
* @param int $value config value
245257
*
246258
* @return Generator<string>
259+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
247260
*
248261
* @since 32.0.0
249262
*/
@@ -260,6 +273,7 @@ public function searchUsersByValueInt(string $app, string $key, int $value): Gen
260273
* @param array $values list of possible config values
261274
*
262275
* @return Generator<string>
276+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
263277
*
264278
* @since 32.0.0
265279
*/
@@ -276,6 +290,7 @@ public function searchUsersByValues(string $app, string $key, array $values): Ge
276290
* @param bool $value config value
277291
*
278292
* @return Generator<string>
293+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
279294
*
280295
* @since 32.0.0
281296
*/
@@ -293,6 +308,7 @@ public function searchUsersByValueBool(string $app, string $key, bool $value): G
293308
* @param bool $lazy search within lazy loaded config
294309
*
295310
* @return string stored config value or $default if not set in database
311+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
296312
*
297313
* @since 32.0.0
298314
*
@@ -316,6 +332,7 @@ public function getValueString(string $userId, string $app, string $key, string
316332
* @param bool $lazy search within lazy loaded config
317333
*
318334
* @return int stored config value or $default if not set in database
335+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
319336
*
320337
* @since 32.0.0
321338
*
@@ -339,6 +356,7 @@ public function getValueInt(string $userId, string $app, string $key, int $defau
339356
* @param bool $lazy search within lazy loaded config
340357
*
341358
* @return float stored config value or $default if not set in database
359+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
342360
*
343361
* @since 32.0.0
344362
*
@@ -362,6 +380,7 @@ public function getValueFloat(string $userId, string $app, string $key, float $d
362380
* @param bool $lazy search within lazy loaded config
363381
*
364382
* @return bool stored config value or $default if not set in database
383+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
365384
*
366385
* @since 32.0.0
367386
*
@@ -385,6 +404,7 @@ public function getValueBool(string $userId, string $app, string $key, bool $def
385404
* @param bool $lazy search within lazy loaded config
386405
*
387406
* @return array stored config value or $default if not set in database
407+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
388408
*
389409
* @since 32.0.0
390410
*
@@ -410,6 +430,7 @@ public function getValueArray(string $userId, string $app, string $key, array $d
410430
* @return ValueType type of the value
411431
* @throws UnknownKeyException if config key is not known
412432
* @throws IncorrectTypeException if config value type is not known
433+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
413434
*
414435
* @since 32.0.0
415436
*/
@@ -429,6 +450,7 @@ public function getValueType(string $userId, string $app, string $key, ?bool $la
429450
* @return int a bitflag in relation to the config value
430451
* @throws UnknownKeyException if config key is not known
431452
* @throws IncorrectTypeException if config value type is not known
453+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
432454
*
433455
* @since 32.0.0
434456
*/
@@ -450,6 +472,7 @@ public function getValueFlags(string $userId, string $app, string $key, bool $la
450472
* @param bool $lazy set config as lazy loaded
451473
*
452474
* @return bool TRUE if value was different, therefor updated in database
475+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
453476
*
454477
* @since 32.0.0
455478
*
@@ -482,6 +505,7 @@ public function setValueString(string $userId, string $app, string $key, string
482505
* @param bool $lazy set config as lazy loaded
483506
*
484507
* @return bool TRUE if value was different, therefor updated in database
508+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
485509
*
486510
* @since 32.0.0
487511
*
@@ -509,6 +533,7 @@ public function setValueInt(string $userId, string $app, string $key, int $value
509533
* @param bool $lazy set config as lazy loaded
510534
*
511535
* @return bool TRUE if value was different, therefor updated in database
536+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
512537
*
513538
* @since 32.0.0
514539
*
@@ -535,6 +560,7 @@ public function setValueFloat(string $userId, string $app, string $key, float $v
535560
* @param bool $lazy set config as lazy loaded
536561
*
537562
* @return bool TRUE if value was different, therefor updated in database
563+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
538564
*
539565
* @since 32.0.0
540566
*
@@ -562,6 +588,7 @@ public function setValueBool(string $userId, string $app, string $key, bool $val
562588
* @param bool $lazy set config as lazy loaded
563589
*
564590
* @return bool TRUE if value was different, therefor updated in database
591+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
565592
*
566593
* @since 32.0.0
567594
*
@@ -584,6 +611,7 @@ public function setValueArray(string $userId, string $app, string $key, array $v
584611
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
585612
*
586613
* @return bool TRUE if database update were necessary
614+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
587615
*
588616
* @since 32.0.0
589617
*/
@@ -597,6 +625,7 @@ public function updateSensitive(string $userId, string $app, string $key, bool $
597625
* @param string $app id of the app
598626
* @param string $key config key
599627
* @param bool $sensitive TRUE to set as sensitive, FALSE to unset
628+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
600629
*
601630
* @since 32.0.0
602631
*/
@@ -614,6 +643,7 @@ public function updateGlobalSensitive(string $app, string $key, bool $sensitive)
614643
* @param bool $indexed TRUE to set as indexed, FALSE to unset
615644
*
616645
* @return bool TRUE if database update were necessary
646+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
617647
*
618648
* @since 32.0.0
619649
*/
@@ -627,6 +657,7 @@ public function updateIndexed(string $userId, string $app, string $key, bool $in
627657
* @param string $app id of the app
628658
* @param string $key config key
629659
* @param bool $indexed TRUE to set as indexed, FALSE to unset
660+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
630661
*
631662
* @since 32.0.0
632663
*/
@@ -641,6 +672,7 @@ public function updateGlobalIndexed(string $app, string $key, bool $indexed): vo
641672
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
642673
*
643674
* @return bool TRUE if database update was necessary
675+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
644676
*
645677
* @since 32.0.0
646678
*/
@@ -654,6 +686,7 @@ public function updateLazy(string $userId, string $app, string $key, bool $lazy)
654686
* @param string $app id of the app
655687
* @param string $key config key
656688
* @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
689+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
657690
*
658691
* @since 32.0.0
659692
*/
@@ -680,6 +713,7 @@ public function updateGlobalLazy(string $app, string $key, bool $lazy): void;
680713
*
681714
* @return array
682715
* @throws UnknownKeyException if config key is not known in database
716+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
683717
*
684718
* @since 32.0.0
685719
*/
@@ -691,6 +725,7 @@ public function getDetails(string $userId, string $app, string $key): array;
691725
* @param string $userId id of the user
692726
* @param string $app id of the app
693727
* @param string $key config key
728+
* @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string)
694729
*
695730
* @since 32.0.0
696731
*/
@@ -701,6 +736,7 @@ public function deleteUserConfig(string $userId, string $app, string $key): void
701736
*
702737
* @param string $app id of the app
703738
* @param string $key config key
739+
* @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string)
704740
*
705741
* @since 32.0.0
706742
*/
@@ -710,6 +746,7 @@ public function deleteKey(string $app, string $key): void;
710746
* delete all config keys linked to an app
711747
*
712748
* @param string $app id of the app
749+
* @throws \InvalidArgumentException if $app is invalid (too long, or empty string)
713750
*
714751
* @since 32.0.0
715752
*/
@@ -719,6 +756,7 @@ public function deleteApp(string $app): void;
719756
* delete all config keys linked to a user
720757
*
721758
* @param string $userId id of the user
759+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
722760
*
723761
* @since 32.0.0
724762
*/
@@ -731,6 +769,7 @@ public function deleteAllUserConfig(string $userId): void;
731769
*
732770
* @param string $userId id of the user
733771
* @param bool $reload set to TRUE to refill cache instantly after clearing it
772+
* @throws \InvalidArgumentException if $userId is invalid (too long, or empty string)
734773
*
735774
* @since 32.0.0
736775
*/

0 commit comments

Comments
 (0)