diff options
Diffstat (limited to 'lib/unstable/Config')
-rw-r--r-- | lib/unstable/Config/Exceptions/IncorrectTypeException.php | 2 | ||||
-rw-r--r-- | lib/unstable/Config/Exceptions/TypeConflictException.php | 2 | ||||
-rw-r--r-- | lib/unstable/Config/Exceptions/UnknownKeyException.php | 2 | ||||
-rw-r--r-- | lib/unstable/Config/IUserConfig.php | 89 | ||||
-rw-r--r-- | lib/unstable/Config/Lexicon/ConfigLexiconEntry.php | 97 | ||||
-rw-r--r-- | lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php | 26 | ||||
-rw-r--r-- | lib/unstable/Config/Lexicon/IConfigLexicon.php | 13 | ||||
-rw-r--r-- | lib/unstable/Config/Lexicon/Preset.php | 75 | ||||
-rw-r--r-- | lib/unstable/Config/ValueType.php | 26 |
9 files changed, 322 insertions, 10 deletions
diff --git a/lib/unstable/Config/Exceptions/IncorrectTypeException.php b/lib/unstable/Config/Exceptions/IncorrectTypeException.php index 274c95d732a..6b91959071a 100644 --- a/lib/unstable/Config/Exceptions/IncorrectTypeException.php +++ b/lib/unstable/Config/Exceptions/IncorrectTypeException.php @@ -12,6 +12,8 @@ use Exception; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Exceptions\IncorrectTypeException + * @see \OCP\Config\Exceptions\IncorrectTypeException */ class IncorrectTypeException extends Exception { } diff --git a/lib/unstable/Config/Exceptions/TypeConflictException.php b/lib/unstable/Config/Exceptions/TypeConflictException.php index c6825b7efcf..808679ed873 100644 --- a/lib/unstable/Config/Exceptions/TypeConflictException.php +++ b/lib/unstable/Config/Exceptions/TypeConflictException.php @@ -12,6 +12,8 @@ use Exception; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Exceptions\TypeConflictException + * @see \OCP\Config\Exceptions\TypeConflictException */ class TypeConflictException extends Exception { } diff --git a/lib/unstable/Config/Exceptions/UnknownKeyException.php b/lib/unstable/Config/Exceptions/UnknownKeyException.php index a3ca88a7b72..744ce25e48d 100644 --- a/lib/unstable/Config/Exceptions/UnknownKeyException.php +++ b/lib/unstable/Config/Exceptions/UnknownKeyException.php @@ -12,6 +12,8 @@ use Exception; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Exceptions\UnknownKeyException + * @see \OCP\Config\Exceptions\UnknownKeyException */ class UnknownKeyException extends Exception { } diff --git a/lib/unstable/Config/IUserConfig.php b/lib/unstable/Config/IUserConfig.php index b9cbb65ad03..bffd6a96ebd 100644 --- a/lib/unstable/Config/IUserConfig.php +++ b/lib/unstable/Config/IUserConfig.php @@ -28,14 +28,20 @@ use NCU\Config\Exceptions\UnknownKeyException; * during specific requests or actions to avoid loading the lazy values all the time. * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ interface IUserConfig { /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public const FLAG_SENSITIVE = 1; // value is sensitive /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public const FLAG_INDEXED = 2; // value should be indexed @@ -50,6 +56,8 @@ interface IUserConfig { * @return list<string> list of userIds * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getUserIds(string $appId = ''): array; @@ -64,6 +72,8 @@ interface IUserConfig { * @return list<string> list of app ids * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getApps(string $userId): array; @@ -79,6 +89,8 @@ interface IUserConfig { * @return list<string> list of stored config keys * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getKeys(string $userId, string $app): array; @@ -93,6 +105,8 @@ interface IUserConfig { * @return bool TRUE if key exists * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool; @@ -108,6 +122,8 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool; @@ -128,6 +144,8 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool; @@ -145,6 +163,8 @@ interface IUserConfig { * @see IUserConfig for details about lazy loading * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function isLazy(string $userId, string $app, string $key): bool; @@ -162,6 +182,8 @@ interface IUserConfig { * @return array<string, string|int|float|bool|array> [key => value] * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getValues(string $userId, string $app, string $prefix = '', bool $filtered = false): array; @@ -177,6 +199,8 @@ interface IUserConfig { * @return array<string, string|int|float|bool|array> [key => value] * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getAllValues(string $userId, bool $filtered = false): array; @@ -192,6 +216,9 @@ interface IUserConfig { * @return array<string, string|int|float|bool|array> [appId => value] * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * @psalm-suppress DeprecatedClass */ public function getValuesByApps(string $userId, string $key, bool $lazy = false, ?ValueType $typedAs = null): array; @@ -209,6 +236,9 @@ interface IUserConfig { * @return array<string, string|int|float|bool|array> [userId => value] * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * @psalm-suppress DeprecatedClass */ public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs = null, ?array $userIds = null): array; @@ -226,6 +256,8 @@ interface IUserConfig { * @return Generator<string> * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function searchUsersByValueString(string $app, string $key, string $value, bool $caseInsensitive = false): Generator; @@ -242,6 +274,8 @@ interface IUserConfig { * @return Generator<string> * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function searchUsersByValueInt(string $app, string $key, int $value): Generator; @@ -258,6 +292,8 @@ interface IUserConfig { * @return Generator<string> * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function searchUsersByValues(string $app, string $key, array $values): Generator; @@ -274,6 +310,8 @@ interface IUserConfig { * @return Generator<string> * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function searchUsersByValueBool(string $app, string $key, bool $value): Generator; @@ -291,6 +329,8 @@ interface IUserConfig { * @return string stored config value or $default if not set in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see getValueInt() @@ -314,6 +354,8 @@ interface IUserConfig { * @return int stored config value or $default if not set in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see getValueString() @@ -337,6 +379,8 @@ interface IUserConfig { * @return float stored config value or $default if not set in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see getValueString() @@ -360,6 +404,8 @@ interface IUserConfig { * @return bool stored config value or $default if not set in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserPrefences for explanation about lazy loading * @see getValueString() @@ -383,6 +429,8 @@ interface IUserConfig { * @return array stored config value or $default if not set in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see getValueString() @@ -408,6 +456,9 @@ interface IUserConfig { * @throws IncorrectTypeException if config value type is not known * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * @psalm-suppress DeprecatedClass */ public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType; @@ -427,6 +478,8 @@ interface IUserConfig { * @throws IncorrectTypeException if config value type is not known * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int; @@ -448,6 +501,8 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see setValueInt() @@ -480,6 +535,8 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -507,6 +564,8 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -533,6 +592,8 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -560,6 +621,8 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -582,6 +645,8 @@ interface IUserConfig { * @return bool TRUE if database update were necessary * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool; @@ -595,6 +660,8 @@ interface IUserConfig { * @param bool $sensitive TRUE to set as sensitive, FALSE to unset * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function updateGlobalSensitive(string $app, string $key, bool $sensitive): void; @@ -612,6 +679,8 @@ interface IUserConfig { * @return bool TRUE if database update were necessary * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool; @@ -625,6 +694,8 @@ interface IUserConfig { * @param bool $indexed TRUE to set as indexed, FALSE to unset * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function updateGlobalIndexed(string $app, string $key, bool $indexed): void; @@ -639,6 +710,8 @@ interface IUserConfig { * @return bool TRUE if database update was necessary * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool; @@ -652,6 +725,8 @@ interface IUserConfig { * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function updateGlobalLazy(string $app, string $key, bool $lazy): void; @@ -678,6 +753,8 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known in database * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function getDetails(string $userId, string $app, string $key): array; @@ -689,6 +766,8 @@ interface IUserConfig { * @param string $key config key * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function deleteUserConfig(string $userId, string $app, string $key): void; @@ -699,6 +778,8 @@ interface IUserConfig { * @param string $key config key * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function deleteKey(string $app, string $key): void; @@ -708,6 +789,8 @@ interface IUserConfig { * @param string $app id of the app * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function deleteApp(string $app): void; @@ -717,6 +800,8 @@ interface IUserConfig { * @param string $userId id of the user * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function deleteAllUserConfig(string $userId): void; @@ -729,6 +814,8 @@ interface IUserConfig { * @param bool $reload set to TRUE to refill cache instantly after clearing it * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function clearCache(string $userId, bool $reload = false): void; @@ -737,6 +824,8 @@ interface IUserConfig { * The cache will be rebuilt only the next time a user config is requested. * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig */ public function clearCacheAll(): void; } diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php index d7d781d8e26..2587cd52c01 100644 --- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php +++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php @@ -8,6 +8,7 @@ declare(strict_types=1); namespace NCU\Config\Lexicon; +use Closure; use NCU\Config\ValueType; /** @@ -15,32 +16,52 @@ use NCU\Config\ValueType; * * @see IConfigLexicon * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @psalm-suppress DeprecatedClass */ class ConfigLexiconEntry { + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public const RENAME_INVERT_BOOLEAN = 1; + private string $definition = ''; private ?string $default = null; /** - * @param string $key config key + * @param string $key config key, can only contain alphanumerical chars and -._ * @param ValueType $type type of config value * @param string $definition optional description of config key available when using occ command * @param bool $lazy set config value as lazy * @param int $flags set flags + * @param string|null $rename previous config key to migrate config value from * @param bool $deprecated set config key as deprecated * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry * @psalm-suppress PossiblyInvalidCast * @psalm-suppress RiskyCast */ public function __construct( private readonly string $key, private readonly ValueType $type, - private null|string|int|float|bool|array $defaultRaw = null, + private null|string|int|float|bool|array|Closure $defaultRaw = null, string $definition = '', private readonly bool $lazy = false, private readonly int $flags = 0, private readonly bool $deprecated = false, + private readonly ?string $rename = null, + private readonly int $options = 0, ) { + // key can only contain alphanumeric chars and underscore "_" + if (preg_match('/[^[:alnum:]_]/', $key)) { + throw new \Exception('invalid config key'); + } + /** @psalm-suppress UndefinedClass */ if (\OC::$CLI) { // only store definition if ran from CLI $this->definition = $definition; @@ -52,6 +73,8 @@ class ConfigLexiconEntry { * * @return string config key * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ public function getKey(): string { return $this->key; @@ -62,6 +85,9 @@ class ConfigLexiconEntry { * * @return ValueType * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @psalm-suppress DeprecatedClass */ public function getValueType(): ValueType { return $this->type; @@ -71,6 +97,8 @@ class ConfigLexiconEntry { * @param string $default * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ private function convertFromString(string $default): string { return $default; @@ -80,6 +108,8 @@ class ConfigLexiconEntry { * @param int $default * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ private function convertFromInt(int $default): string { return (string)$default; @@ -89,6 +119,8 @@ class ConfigLexiconEntry { * @param float $default * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ private function convertFromFloat(float $default): string { return (string)$default; @@ -98,6 +130,8 @@ class ConfigLexiconEntry { * @param bool $default * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ private function convertFromBool(bool $default): string { return ($default) ? '1' : '0'; @@ -107,6 +141,8 @@ class ConfigLexiconEntry { * @param array $default * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ private function convertFromArray(array $default): string { return json_encode($default); @@ -117,16 +153,28 @@ class ConfigLexiconEntry { * * @return string|null NULL if no default is set * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @psalm-suppress DeprecatedClass + * @psalm-suppress DeprecatedMethod */ - public function getDefault(): ?string { + public function getDefault(Preset $preset): ?string { + if ($this->default !== null) { + return $this->default; + } + if ($this->defaultRaw === null) { return null; } - if ($this->default === null) { - $this->default = $this->convertToString($this->defaultRaw); + if ($this->defaultRaw instanceof Closure) { + /** @psalm-suppress MixedAssignment we expect closure to returns string|int|float|bool|array */ + $this->defaultRaw = ($this->defaultRaw)($preset); } + /** @psalm-suppress MixedArgument closure should be managed previously */ + $this->default = $this->convertToString($this->defaultRaw); + return $this->default; } @@ -137,8 +185,13 @@ class ConfigLexiconEntry { * * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry * @psalm-suppress PossiblyInvalidCast arrays are managed pre-cast * @psalm-suppress RiskyCast + * @psalm-suppress DeprecatedClass + * @psalm-suppress DeprecatedMethod + * @psalm-suppress DeprecatedConstant */ public function convertToString(string|int|float|bool|array $entry): string { // in case $default is array but is not expected to be an array... @@ -161,6 +214,8 @@ class ConfigLexiconEntry { * * @return string * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ public function getDefinition(): string { return $this->definition; @@ -172,6 +227,8 @@ class ConfigLexiconEntry { * @see IAppConfig for details on lazy config values * @return bool TRUE if config value is lazy * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ public function isLazy(): bool { return $this->lazy; @@ -183,6 +240,8 @@ class ConfigLexiconEntry { * @see IAppConfig for details on sensitive config values * @return int bitflag about the config value * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ public function getFlags(): int { return $this->flags; @@ -193,16 +252,44 @@ class ConfigLexiconEntry { * * @return bool TRUE is config value bitflag contains $flag * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @psalm-suppress DeprecatedMethod */ public function isFlagged(int $flag): bool { return (($flag & $this->getFlags()) === $flag); } /** + * should be called/used only during migration/upgrade. + * link to an old config key. + * + * @return string|null not NULL if value can be imported from a previous key + * @experimental 32.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public function getRename(): ?string { + return $this->rename; + } + + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @return bool TRUE if $option was set during the creation of the entry. + */ + public function hasOption(int $option): bool { + return (($option & $this->options) !== 0); + } + + /** * returns if config key is set as deprecated * * @return bool TRUE if config si deprecated * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry */ public function isDeprecated(): bool { return $this->deprecated; diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php index a6490675c8a..2ccd7bd265c 100644 --- a/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php +++ b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php @@ -17,14 +17,32 @@ namespace NCU\Config\Lexicon; * - **ConfigLexiconStrictness::EXCEPTION** - block (throws exception) and report * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness + * @see \OCP\Config\Lexicon\Strictness */ enum ConfigLexiconStrictness { - /** @experimental 31.0.0 */ + /** + * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness + * @see \OCP\Config\Lexicon\Strictness + */ case IGNORE; // fully ignore - /** @experimental 31.0.0 */ + /** + * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness + * @see \OCP\Config\Lexicon\Strictness + */ case NOTICE; // ignore and report - /** @experimental 31.0.0 */ + /** + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness + * @see \OCP\Config\Lexicon\Strictness + * @experimental 31.0.0 + */ case WARNING; // silently block (returns $default) and report - /** @experimental 31.0.0 */ + /** + * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness + * @see \OCP\Config\Lexicon\Strictness + */ case EXCEPTION; // block (throws exception) and report } diff --git a/lib/unstable/Config/Lexicon/IConfigLexicon.php b/lib/unstable/Config/Lexicon/IConfigLexicon.php index 3fedb5f1f08..74dc19e7728 100644 --- a/lib/unstable/Config/Lexicon/IConfigLexicon.php +++ b/lib/unstable/Config/Lexicon/IConfigLexicon.php @@ -13,6 +13,8 @@ namespace NCU\Config\Lexicon; * The config lexicon is used to avoid conflicts and problems when storing/retrieving config values * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon + * @see \OCP\Config\Lexicon\ILexicon */ interface IConfigLexicon { @@ -20,9 +22,12 @@ interface IConfigLexicon { * Define the expected behavior when using config * keys not set within your application config lexicon. * - * @see ConfigLexiconStrictness * @return ConfigLexiconStrictness * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon + * @see \OCP\Config\Lexicon\ILexicon + * @psalm-suppress DeprecatedClass + * */ public function getStrictness(): ConfigLexiconStrictness; @@ -31,6 +36,9 @@ interface IConfigLexicon { * * @return ConfigLexiconEntry[] * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon + * @see \OCP\Config\Lexicon\ILexicon + * @psalm-suppress DeprecatedClass */ public function getAppConfigs(): array; @@ -39,6 +47,9 @@ interface IConfigLexicon { * * @return ConfigLexiconEntry[] * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon + * @see \OCP\Config\Lexicon\ILexicon + * @psalm-suppress DeprecatedClass */ public function getUserConfigs(): array; } diff --git a/lib/unstable/Config/Lexicon/Preset.php b/lib/unstable/Config/Lexicon/Preset.php new file mode 100644 index 00000000000..b2a98ed5647 --- /dev/null +++ b/lib/unstable/Config/Lexicon/Preset.php @@ -0,0 +1,75 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +namespace NCU\Config\Lexicon; + +/** + * list of preset to handle the default behavior of the instance + * + * @see ConfigLexiconEntry::preset + * + * - **Preset::LARGE** - Large size organisation (> 50k accounts) + * - **Preset::MEDIUM** - Medium size organisation (> 100 accounts) + * - **Preset::SMALL** - Small size organisation (< 100 accounts) + * - **Preset::SHARED** - Shared hosting + * - **Preset::EDUCATION** - School/University + * - **Preset::CLUB** - Club/Association + * - **Preset::FAMILY** - Family + * - **Preset::PRIVATE** - Private + * + * @experimental 32.0.0 + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Preset + * @see \OCP\Config\Lexicon\Preset + */ +enum Preset: int { + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case LARGE = 8; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case MEDIUM = 7; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case SMALL = 6; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case SHARED = 5; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case EDUCATION = 4; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case CLUB = 3; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case FAMILY = 2; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case PRIVATE = 1; + /** + * @experimental 32.0.0 + * @deprecated 32.0.0 + */ + case NONE = 0; +} diff --git a/lib/unstable/Config/ValueType.php b/lib/unstable/Config/ValueType.php index b1181674953..73714640445 100644 --- a/lib/unstable/Config/ValueType.php +++ b/lib/unstable/Config/ValueType.php @@ -16,30 +16,44 @@ use UnhandledMatchError; * Listing of available value type for typed config value * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ enum ValueType: int { /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ case MIXED = 0; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ case STRING = 1; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ case INT = 2; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ case FLOAT = 3; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ case BOOL = 4; /** * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType */ case ARRAY = 5; @@ -52,6 +66,10 @@ enum ValueType: int { * @throws IncorrectTypeException * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType + * @psalm-suppress DeprecatedConstant + * @psalm-suppress DeprecatedClass */ public static function fromStringDefinition(string $definition): self { try { @@ -75,6 +93,10 @@ enum ValueType: int { * @throws IncorrectTypeException * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType + * @psalm-suppress DeprecatedConstant + * @psalm-suppress DeprecatedClass */ public function getDefinition(): string { try { @@ -98,6 +120,10 @@ enum ValueType: int { * @throws IncorrectTypeException * * @experimental 31.0.0 + * @deprecated 32.0.0 use \OCP\Config\ValueType + * @see \OCP\Config\ValueType + * @psalm-suppress DeprecatedConstant + * @psalm-suppress DeprecatedClass */ public function toAppConfigFlag(): int { try { |