Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Joas Schilling <[email protected]>
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl and nickvergessen authored Dec 8, 2023
1 parent ecd9405 commit 57dd3bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
10 changes: 5 additions & 5 deletions lib/private/AllConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function deleteSystemValue($key) {
*
* @param string $appName the appName that we stored the value under
* @return string[] the keys stored for the app
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function getAppKeys($appName) {
return \OC::$server->get(AppConfig::class)->getKeys($appName);
Expand All @@ -202,7 +202,7 @@ public function getAppKeys($appName) {
* @param string $appName the appName that we want to store the value under
* @param string $key the key of the value, under which will be saved
* @param string|float|int $value the value that should be stored
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function setAppValue($appName, $key, $value) {
\OC::$server->get(AppConfig::class)->setValue($appName, $key, $value);
Expand All @@ -215,7 +215,7 @@ public function setAppValue($appName, $key, $value) {
* @param string $key the key of the value, under which it was saved
* @param string $default the default value to be returned if the value isn't set
* @return string the saved value
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function getAppValue($appName, $key, $default = '') {
return \OC::$server->get(AppConfig::class)->getValue($appName, $key, $default);
Expand All @@ -226,7 +226,7 @@ public function getAppValue($appName, $key, $default = '') {
*
* @param string $appName the appName that we stored the value under
* @param string $key the key of the value, under which it was saved
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function deleteAppValue($appName, $key) {
\OC::$server->get(AppConfig::class)->deleteKey($appName, $key);
Expand All @@ -236,7 +236,7 @@ public function deleteAppValue($appName, $key) {
* Removes all keys in appconfig belonging to the app
*
* @param string $appName the appName the configs are stored under
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function deleteAppValues($appName) {
\OC::$server->get(AppConfig::class)->deleteApp($appName);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function getValueFloat(string $app, string $key, float $default = 0, bool
*/
public function getValueBool(string $app, string $key, bool $default = false, bool $lazy = false): bool {
return in_array(
$this->getValueString($app, $key, $default ? 'true' : 'false'), ['1', 'true', 'yes', 'on'], $lazy
$this->getValueString($app, $key, $default ? 'true' : 'false', $lazy), ['1', 'true', 'yes', 'on']
);
}

Expand All @@ -380,7 +380,7 @@ public function getValueArray(string $app, string $key, array $default = [], boo
$this->getValueString($app, $key, $defaultJson, $lazy), true, JSON_THROW_ON_ERROR
);

return (is_array($value)) ? $value : [$value];
return is_array($value) ? $value : [];
} catch (JsonException) {
return [];
}
Expand Down
18 changes: 4 additions & 14 deletions lib/public/IAppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function getValueArray(string $app, string $key, array $default = [], boo
* @param string $key config key
* @param string $value config value
* @param bool|null $sensitive value should be hidden when needed. if NULL sensitive flag is not changed in database

Check failure on line 255 in lib/public/IAppConfig.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

MismatchingDocblockParamType

lib/public/IAppConfig.php:255:12: MismatchingDocblockParamType: Parameter $sensitive has wrong type 'bool|null', should be 'bool' (see https://psalm.dev/141)

Check failure

Code scanning / Psalm

MismatchingDocblockParamType Error

Parameter $sensitive has wrong type 'bool|null', should be 'bool'
* @param string $lazy name of the lazy group
* @param bool $lazy set config as lazy loaded
*
* @return bool TRUE if value was different, therefor updated in database
* @since 29.0.0
Expand All @@ -263,7 +263,7 @@ public function getValueArray(string $app, string $key, array $default = [], boo
* @see self::setValueBool()
* @see self::setValueArray()
*/
public function setValueString(string $app, string $key, string $value, bool $lazy = false, ?bool $sensitive = null): bool;
public function setValueString(string $app, string $key, string $value, bool $sensitive, bool $lazy = false): bool;

/**
* Store a config key and its value in database
Expand Down Expand Up @@ -385,37 +385,27 @@ public function clearCache(): void;
*/
public function statusCache(): array;

/*
*
* #######################################################################
* # Below this mark are the method deprecated and replaced since 29.0.0 #
* #######################################################################
*
*/

/**
* get multiply values, either the app or key can be used as wildcard by setting it to false
* @deprecated use getAllValues()
*
* @param string|false $key
* @param string|false $app
*
* @return array|false
* @since 7.0.0
* @deprecated use getAllValues()
* @see self::getAllValues()
* @deprecated 29.0.0 Use {@see getAllValues()}
*/
public function getValues($app, $key);

/**
* get all values of the app or and filters out sensitive data
* @deprecated use getAllValues()
*
* @param string $app
*
* @return array
* @since 12.0.0
* @see self::getAllValues()
* @deprecated 29.0.0 Use {@see getAllValues()}
*/
public function getFilteredValues($app);
}
10 changes: 5 additions & 5 deletions lib/public/IConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function deleteSystemValue($key);
* @param string $appName the appName that we stored the value under
* @return string[] the keys stored for the app
* @since 8.0.0
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function getAppKeys($appName);

Expand All @@ -138,7 +138,7 @@ public function getAppKeys($appName);
* @param string $value the value that should be stored
* @return void
* @since 6.0.0
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function setAppValue($appName, $key, $value);

Expand All @@ -151,7 +151,7 @@ public function setAppValue($appName, $key, $value);
*
* @return string the saved value
* @since 6.0.0 - parameter $default was added in 7.0.0
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function getAppValue($appName, $key, $default = '');

Expand All @@ -161,7 +161,7 @@ public function getAppValue($appName, $key, $default = '');
* @param string $appName the appName that we stored the value under
* @param string $key the key of the value, under which it was saved
* @since 8.0.0
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function deleteAppValue($appName, $key);

Expand All @@ -170,7 +170,7 @@ public function deleteAppValue($appName, $key);
*
* @param string $appName the appName the configs are stored under
* @since 8.0.0
* @deprecated - load IAppConfig directly
* @deprecated 29.0.0 Use {@see IAppConfig} directly
*/
public function deleteAppValues($appName);

Expand Down

0 comments on commit 57dd3bd

Please sign in to comment.