From 33bff30e1d0230979844e0481654673900eafb6e Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 16 Jul 2025 12:46:45 -0100 Subject: [PATCH 1/5] feat(lexicon): moving out from unstable Signed-off-by: Maxence Lange --- apps/files_external/lib/ConfigLexicon.php | 20 ++-- .../lib/Config/ConfigLexicon.php | 18 ++-- .../Version2006Date20240905111627Test.php | 2 +- core/Command/Config/Preset.php | 2 +- lib/composer/composer/autoload_classmap.php | 18 ++-- lib/composer/composer/autoload_static.php | 18 ++-- lib/composer/composer/platform_check.php | 5 +- lib/private/AllConfig.php | 6 +- lib/private/AppConfig.php | 30 +++--- .../Bootstrap/RegistrationContext.php | 8 +- lib/private/Config/ConfigManager.php | 23 ++--- .../Config/Lexicon/CoreConfigLexicon.php | 22 ++--- lib/private/Config/UserConfig.php | 46 ++++----- lib/private/Server.php | 3 +- .../Bootstrap/IRegistrationContext.php | 2 +- .../Exceptions/IncorrectTypeException.php | 4 +- .../Exceptions/TypeConflictException.php | 4 +- .../Config/Exceptions/UnknownKeyException.php | 4 +- .../Config/IUserConfig.php | 92 +++++++++--------- .../Config/Lexicon/Entry.php} | 46 ++++----- .../Config/Lexicon/ILexicon.php} | 22 ++--- .../Config/Lexicon/Preset.php | 24 ++--- lib/public/Config/Lexicon/Strictness.php | 30 ++++++ lib/{unstable => public}/Config/ValueType.php | 24 ++--- .../Lexicon/ConfigLexiconStrictness.php | 30 ------ tests/lib/Config/LexiconTest.php | 94 +++++++++---------- tests/lib/Config/TestConfigLexicon_E.php | 49 ---------- tests/lib/Config/TestConfigLexicon_I.php | 28 +++--- tests/lib/Config/TestConfigLexicon_N.php | 39 -------- tests/lib/Config/TestConfigLexicon_W.php | 39 -------- tests/lib/Config/TestLexicon_E.php | 49 ++++++++++ tests/lib/Config/TestLexicon_N.php | 39 ++++++++ tests/lib/Config/TestLexicon_W.php | 39 ++++++++ tests/lib/Config/UserConfigTest.php | 8 +- 34 files changed, 444 insertions(+), 443 deletions(-) rename lib/{unstable => public}/Config/Exceptions/IncorrectTypeException.php (80%) rename lib/{unstable => public}/Config/Exceptions/TypeConflictException.php (80%) rename lib/{unstable => public}/Config/Exceptions/UnknownKeyException.php (80%) rename lib/{unstable => public}/Config/IUserConfig.php (95%) rename lib/{unstable/Config/Lexicon/ConfigLexiconEntry.php => public/Config/Lexicon/Entry.php} (90%) rename lib/{unstable/Config/Lexicon/IConfigLexicon.php => public/Config/Lexicon/ILexicon.php} (69%) rename lib/{unstable => public}/Config/Lexicon/Preset.php (70%) create mode 100644 lib/public/Config/Lexicon/Strictness.php rename lib/{unstable => public}/Config/ValueType.php (86%) delete mode 100644 lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php delete mode 100644 tests/lib/Config/TestConfigLexicon_E.php delete mode 100644 tests/lib/Config/TestConfigLexicon_N.php delete mode 100644 tests/lib/Config/TestConfigLexicon_W.php create mode 100644 tests/lib/Config/TestLexicon_E.php create mode 100644 tests/lib/Config/TestLexicon_N.php create mode 100644 tests/lib/Config/TestLexicon_W.php diff --git a/apps/files_external/lib/ConfigLexicon.php b/apps/files_external/lib/ConfigLexicon.php index e162efc92cf..154f76c1989 100644 --- a/apps/files_external/lib/ConfigLexicon.php +++ b/apps/files_external/lib/ConfigLexicon.php @@ -8,30 +8,30 @@ declare(strict_types=1); namespace OCA\Files_External; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; /** * Config Lexicon for files_sharing. * * Please Add & Manage your Config Keys in that file and keep the Lexicon up to date! * - * {@see IConfigLexicon} + * {@see ILexicon} */ -class ConfigLexicon implements IConfigLexicon { +class ConfigLexicon implements ILexicon { public const ALLOW_USER_MOUNTING = 'allow_user_mounting'; public const USER_MOUNTING_BACKENDS = 'user_mounting_backends'; - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::NOTICE; + public function getStrictness(): Strictness { + return Strictness::NOTICE; } public function getAppConfigs(): array { return [ - new ConfigLexiconEntry(self::ALLOW_USER_MOUNTING, ValueType::BOOL, false, 'allow users to mount their own external filesystems', true), - new ConfigLexiconEntry(self::USER_MOUNTING_BACKENDS, ValueType::STRING, '', 'list of mounting backends available for users', true), + new Entry(self::ALLOW_USER_MOUNTING, ValueType::BOOL, false, 'allow users to mount their own external filesystems', true), + new Entry(self::USER_MOUNTING_BACKENDS, ValueType::STRING, '', 'list of mounting backends available for users', true), ]; } diff --git a/apps/files_sharing/lib/Config/ConfigLexicon.php b/apps/files_sharing/lib/Config/ConfigLexicon.php index a463b4e7ef2..3211c755fc7 100644 --- a/apps/files_sharing/lib/Config/ConfigLexicon.php +++ b/apps/files_sharing/lib/Config/ConfigLexicon.php @@ -8,28 +8,28 @@ declare(strict_types=1); namespace OCA\Files_Sharing\Config; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; /** * Config Lexicon for files_sharing. * * Please Add & Manage your Config Keys in that file and keep the Lexicon up to date! * - * {@see IConfigLexicon} + * {@see ILexicon} */ -class ConfigLexicon implements IConfigLexicon { +class ConfigLexicon implements ILexicon { public const SHOW_FEDERATED_AS_INTERNAL = 'show_federated_shares_as_internal'; - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::IGNORE; + public function getStrictness(): Strictness { + return Strictness::IGNORE; } public function getAppConfigs(): array { return [ - new ConfigLexiconEntry(self::SHOW_FEDERATED_AS_INTERNAL, ValueType::BOOL, false, 'shows federated shares as internal shares', true), + new Entry(self::SHOW_FEDERATED_AS_INTERNAL, ValueType::BOOL, false, 'shows federated shares as internal shares', true), ]; } diff --git a/apps/theming/tests/Migration/Version2006Date20240905111627Test.php b/apps/theming/tests/Migration/Version2006Date20240905111627Test.php index c4bcb75b364..5f7458db11a 100644 --- a/apps/theming/tests/Migration/Version2006Date20240905111627Test.php +++ b/apps/theming/tests/Migration/Version2006Date20240905111627Test.php @@ -9,9 +9,9 @@ declare(strict_types=1); namespace OCA\Theming\Tests\Migration; -use NCU\Config\IUserConfig; use OCA\Theming\Migration\Version2006Date20240905111627; use OCP\BackgroundJob\IJobList; +use OCP\Config\IUserConfig; use OCP\IAppConfig; use OCP\IDBConnection; use OCP\IUserManager; diff --git a/core/Command/Config/Preset.php b/core/Command/Config/Preset.php index 9f1424dcc54..4f0278896db 100644 --- a/core/Command/Config/Preset.php +++ b/core/Command/Config/Preset.php @@ -8,9 +8,9 @@ declare(strict_types=1); */ namespace OC\Core\Command\Config; -use NCU\Config\Lexicon\Preset as ConfigLexiconPreset; use OC\Config\ConfigManager; use OC\Core\Command\Base; +use OCP\Config\Lexicon\Preset as ConfigLexiconPreset; use OCP\IConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 16926e77775..8586e1e9c31 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -7,15 +7,6 @@ $baseDir = dirname(dirname($vendorDir)); return array( 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'NCU\\Config\\Exceptions\\IncorrectTypeException' => $baseDir . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php', - 'NCU\\Config\\Exceptions\\TypeConflictException' => $baseDir . '/lib/unstable/Config/Exceptions/TypeConflictException.php', - 'NCU\\Config\\Exceptions\\UnknownKeyException' => $baseDir . '/lib/unstable/Config/Exceptions/UnknownKeyException.php', - 'NCU\\Config\\IUserConfig' => $baseDir . '/lib/unstable/Config/IUserConfig.php', - 'NCU\\Config\\Lexicon\\ConfigLexiconEntry' => $baseDir . '/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php', - 'NCU\\Config\\Lexicon\\ConfigLexiconStrictness' => $baseDir . '/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php', - 'NCU\\Config\\Lexicon\\IConfigLexicon' => $baseDir . '/lib/unstable/Config/Lexicon/IConfigLexicon.php', - 'NCU\\Config\\Lexicon\\Preset' => $baseDir . '/lib/unstable/Config/Lexicon/Preset.php', - 'NCU\\Config\\ValueType' => $baseDir . '/lib/unstable/Config/ValueType.php', 'NCU\\Federation\\ISignedCloudFederationProvider' => $baseDir . '/lib/unstable/Federation/ISignedCloudFederationProvider.php', 'NCU\\Security\\Signature\\Enum\\DigestAlgorithm' => $baseDir . '/lib/unstable/Security/Signature/Enum/DigestAlgorithm.php', 'NCU\\Security\\Signature\\Enum\\SignatoryStatus' => $baseDir . '/lib/unstable/Security/Signature/Enum/SignatoryStatus.php', @@ -275,6 +266,15 @@ return array( 'OCP\\Common\\Exception\\NotFoundException' => $baseDir . '/lib/public/Common/Exception/NotFoundException.php', 'OCP\\Config\\BeforePreferenceDeletedEvent' => $baseDir . '/lib/public/Config/BeforePreferenceDeletedEvent.php', 'OCP\\Config\\BeforePreferenceSetEvent' => $baseDir . '/lib/public/Config/BeforePreferenceSetEvent.php', + 'OCP\\Config\\Exceptions\\IncorrectTypeException' => $baseDir . '/lib/public/Config/Exceptions/IncorrectTypeException.php', + 'OCP\\Config\\Exceptions\\TypeConflictException' => $baseDir . '/lib/public/Config/Exceptions/TypeConflictException.php', + 'OCP\\Config\\Exceptions\\UnknownKeyException' => $baseDir . '/lib/public/Config/Exceptions/UnknownKeyException.php', + 'OCP\\Config\\IUserConfig' => $baseDir . '/lib/public/Config/IUserConfig.php', + 'OCP\\Config\\Lexicon\\Entry' => $baseDir . '/lib/public/Config/Lexicon/Entry.php', + 'OCP\\Config\\Lexicon\\ILexicon' => $baseDir . '/lib/public/Config/Lexicon/ILexicon.php', + 'OCP\\Config\\Lexicon\\Preset' => $baseDir . '/lib/public/Config/Lexicon/Preset.php', + 'OCP\\Config\\Lexicon\\Strictness' => $baseDir . '/lib/public/Config/Lexicon/Strictness.php', + 'OCP\\Config\\ValueType' => $baseDir . '/lib/public/Config/ValueType.php', 'OCP\\Console\\ConsoleEvent' => $baseDir . '/lib/public/Console/ConsoleEvent.php', 'OCP\\Console\\ReservedOptions' => $baseDir . '/lib/public/Console/ReservedOptions.php', 'OCP\\Constants' => $baseDir . '/lib/public/Constants.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index daa1a1940dd..d9362634b63 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -48,15 +48,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 public static $classMap = array ( 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'NCU\\Config\\Exceptions\\IncorrectTypeException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php', - 'NCU\\Config\\Exceptions\\TypeConflictException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/TypeConflictException.php', - 'NCU\\Config\\Exceptions\\UnknownKeyException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/UnknownKeyException.php', - 'NCU\\Config\\IUserConfig' => __DIR__ . '/../../..' . '/lib/unstable/Config/IUserConfig.php', - 'NCU\\Config\\Lexicon\\ConfigLexiconEntry' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php', - 'NCU\\Config\\Lexicon\\ConfigLexiconStrictness' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php', - 'NCU\\Config\\Lexicon\\IConfigLexicon' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/IConfigLexicon.php', - 'NCU\\Config\\Lexicon\\Preset' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/Preset.php', - 'NCU\\Config\\ValueType' => __DIR__ . '/../../..' . '/lib/unstable/Config/ValueType.php', 'NCU\\Federation\\ISignedCloudFederationProvider' => __DIR__ . '/../../..' . '/lib/unstable/Federation/ISignedCloudFederationProvider.php', 'NCU\\Security\\Signature\\Enum\\DigestAlgorithm' => __DIR__ . '/../../..' . '/lib/unstable/Security/Signature/Enum/DigestAlgorithm.php', 'NCU\\Security\\Signature\\Enum\\SignatoryStatus' => __DIR__ . '/../../..' . '/lib/unstable/Security/Signature/Enum/SignatoryStatus.php', @@ -316,6 +307,15 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Common\\Exception\\NotFoundException' => __DIR__ . '/../../..' . '/lib/public/Common/Exception/NotFoundException.php', 'OCP\\Config\\BeforePreferenceDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Config/BeforePreferenceDeletedEvent.php', 'OCP\\Config\\BeforePreferenceSetEvent' => __DIR__ . '/../../..' . '/lib/public/Config/BeforePreferenceSetEvent.php', + 'OCP\\Config\\Exceptions\\IncorrectTypeException' => __DIR__ . '/../../..' . '/lib/public/Config/Exceptions/IncorrectTypeException.php', + 'OCP\\Config\\Exceptions\\TypeConflictException' => __DIR__ . '/../../..' . '/lib/public/Config/Exceptions/TypeConflictException.php', + 'OCP\\Config\\Exceptions\\UnknownKeyException' => __DIR__ . '/../../..' . '/lib/public/Config/Exceptions/UnknownKeyException.php', + 'OCP\\Config\\IUserConfig' => __DIR__ . '/../../..' . '/lib/public/Config/IUserConfig.php', + 'OCP\\Config\\Lexicon\\Entry' => __DIR__ . '/../../..' . '/lib/public/Config/Lexicon/Entry.php', + 'OCP\\Config\\Lexicon\\ILexicon' => __DIR__ . '/../../..' . '/lib/public/Config/Lexicon/ILexicon.php', + 'OCP\\Config\\Lexicon\\Preset' => __DIR__ . '/../../..' . '/lib/public/Config/Lexicon/Preset.php', + 'OCP\\Config\\Lexicon\\Strictness' => __DIR__ . '/../../..' . '/lib/public/Config/Lexicon/Strictness.php', + 'OCP\\Config\\ValueType' => __DIR__ . '/../../..' . '/lib/public/Config/ValueType.php', 'OCP\\Console\\ConsoleEvent' => __DIR__ . '/../../..' . '/lib/public/Console/ConsoleEvent.php', 'OCP\\Console\\ReservedOptions' => __DIR__ . '/../../..' . '/lib/public/Console/ReservedOptions.php', 'OCP\\Constants' => __DIR__ . '/../../..' . '/lib/public/Constants.php', diff --git a/lib/composer/composer/platform_check.php b/lib/composer/composer/platform_check.php index 4c3a5d68f14..2beb1491838 100644 --- a/lib/composer/composer/platform_check.php +++ b/lib/composer/composer/platform_check.php @@ -19,8 +19,7 @@ if ($issues) { echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; } } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR + throw new \RuntimeException( + 'Composer detected issues in your platform: ' . implode(' ', $issues) ); } diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 8a6bb5a4723..c80ee52eb0d 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -7,11 +7,11 @@ */ namespace OC; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\IUserConfig; -use NCU\Config\ValueType; use OC\Config\UserConfig; use OCP\Cache\CappedMemoryCache; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\IUserConfig; +use OCP\Config\ValueType; use OCP\IConfig; use OCP\IDBConnection; use OCP\PreConditionNotMetException; diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index f050deba1ca..0a46109c9f9 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -11,12 +11,12 @@ namespace OC; use InvalidArgumentException; use JsonException; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\Lexicon\Preset; use OC\AppFramework\Bootstrap\Coordinator; use OC\Config\ConfigManager; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Preset; +use OCP\Config\Lexicon\Strictness; use OCP\DB\Exception as DBException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Exceptions\AppConfigIncorrectTypeException; @@ -62,7 +62,7 @@ class AppConfig implements IAppConfig { private array $valueTypes = []; // type for all config values private bool $fastLoaded = false; private bool $lazyLoaded = false; - /** @var array, aliases: array, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ + /** @var array, aliases: array, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; private ?Preset $configLexiconPreset = null; @@ -1655,7 +1655,7 @@ class AppConfig implements IAppConfig { return true; } - /** @var ConfigLexiconEntry $configValue */ + /** @var Entry $configValue */ $configValue = $configDetails['entries'][$key]; $type &= ~self::VALUE_SENSITIVE; @@ -1685,15 +1685,15 @@ class AppConfig implements IAppConfig { /** * manage ConfigLexicon behavior based on strictness set in IConfigLexicon * - * @param ConfigLexiconStrictness|null $strictness + * @param Strictness|null $strictness * @param string $line * * @return bool TRUE if conflict can be fully ignored, FALSE if action should be not performed * @throws AppConfigUnknownKeyException if strictness implies exception - * @see IConfigLexicon::getStrictness() + * @see ILexicon::getStrictness() */ private function applyLexiconStrictness( - ?ConfigLexiconStrictness $strictness, + ?Strictness $strictness, string $line = '', ): bool { if ($strictness === null) { @@ -1701,12 +1701,12 @@ class AppConfig implements IAppConfig { } switch ($strictness) { - case ConfigLexiconStrictness::IGNORE: + case Strictness::IGNORE: return true; - case ConfigLexiconStrictness::NOTICE: + case Strictness::NOTICE: $this->logger->notice($line); return true; - case ConfigLexiconStrictness::WARNING: + case Strictness::WARNING: $this->logger->warning($line); return false; } @@ -1720,7 +1720,7 @@ class AppConfig implements IAppConfig { * @param string $appId * @internal * - * @return array{entries: array, aliases: array, strictness: ConfigLexiconStrictness} + * @return array{entries: array, aliases: array, strictness: Strictness} */ public function getConfigDetailsFromLexicon(string $appId): array { if (!array_key_exists($appId, $this->configLexiconDetails)) { @@ -1737,14 +1737,14 @@ class AppConfig implements IAppConfig { $this->configLexiconDetails[$appId] = [ 'entries' => $entries, 'aliases' => $aliases, - 'strictness' => $configLexicon?->getStrictness() ?? ConfigLexiconStrictness::IGNORE + 'strictness' => $configLexicon?->getStrictness() ?? Strictness::IGNORE ]; } return $this->configLexiconDetails[$appId]; } - private function getLexiconEntry(string $appId, string $key): ?ConfigLexiconEntry { + private function getLexiconEntry(string $appId, string $key): ?Entry { return $this->getConfigDetailsFromLexicon($appId)['entries'][$key] ?? null; } diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index 95ad129c466..94250aad37b 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -10,7 +10,6 @@ declare(strict_types=1); namespace OC\AppFramework\Bootstrap; use Closure; -use NCU\Config\Lexicon\IConfigLexicon; use OC\Config\Lexicon\CoreConfigLexicon; use OC\Support\CrashReport\Registry; use OCP\AppFramework\App; @@ -23,6 +22,7 @@ use OCP\Calendar\Resource\IBackend as IResourceBackend; use OCP\Calendar\Room\IBackend as IRoomBackend; use OCP\Capabilities\ICapability; use OCP\Collaboration\Reference\IReferenceProvider; +use OCP\Config\Lexicon\ILexicon; use OCP\Dashboard\IManager; use OCP\Dashboard\IWidget; use OCP\EventDispatcher\IEventDispatcher; @@ -652,7 +652,7 @@ class RegistrationContext { } /** - * @psalm-param class-string $configLexiconClass + * @psalm-param class-string $configLexiconClass */ public function registerConfigLexicon(string $appId, string $configLexiconClass): void { $this->configLexiconClasses[$appId] = $configLexiconClass; @@ -1023,9 +1023,9 @@ class RegistrationContext { * * @param string $appId * - * @return IConfigLexicon|null + * @return ILexicon|null */ - public function getConfigLexicon(string $appId): ?IConfigLexicon { + public function getConfigLexicon(string $appId): ?ILexicon { if (!array_key_exists($appId, $this->configLexiconClasses)) { return null; } diff --git a/lib/private/Config/ConfigManager.php b/lib/private/Config/ConfigManager.php index 67466617941..ed516abdcbf 100644 --- a/lib/private/Config/ConfigManager.php +++ b/lib/private/Config/ConfigManager.php @@ -9,13 +9,13 @@ declare(strict_types=1); namespace OC\Config; use JsonException; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\Preset; -use NCU\Config\ValueType; use OC\AppConfig; use OCP\App\IAppManager; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\IUserConfig; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\Preset; +use OCP\Config\ValueType; use OCP\IAppConfig; use OCP\IConfig; use OCP\Server; @@ -50,10 +50,11 @@ class ConfigManager { * * This method should be mainly called during a new upgrade or when a new app is enabled. * - * @see ConfigLexiconEntry + * @param string|null $appId when set to NULL the method will be executed for all enabled apps of the instance + * * @internal * @since 32.0.0 - * @param string|null $appId when set to NULL the method will be executed for all enabled apps of the instance + * @see Entry */ public function migrateConfigLexiconKeys(?string $appId = null): void { if ($appId === null) { @@ -166,7 +167,7 @@ class ConfigManager { * * @throws TypeConflictException if previous value does not fit the expected type */ - private function migrateAppConfigValue(string $appId, ConfigLexiconEntry $entry): void { + private function migrateAppConfigValue(string $appId, Entry $entry): void { $value = $this->appConfig->getValueMixed($appId, $entry->getRename(), lazy: null); switch ($entry->getValueType()) { case ValueType::STRING: @@ -196,7 +197,7 @@ class ConfigManager { * * @throws TypeConflictException if previous value does not fit the expected type */ - private function migrateUserConfigValue(string $userId, string $appId, ConfigLexiconEntry $entry): void { + private function migrateUserConfigValue(string $userId, string $appId, Entry $entry): void { $value = $this->userConfig->getValueMixed($userId, $appId, $entry->getRename(), lazy: null); switch ($entry->getValueType()) { case ValueType::STRING: @@ -237,7 +238,7 @@ class ConfigManager { return (float)$value; } - public function convertToBool(string $value, ?ConfigLexiconEntry $entry = null): bool { + public function convertToBool(string $value, ?Entry $entry = null): bool { if (in_array(strtolower($value), ['true', '1', 'on', 'yes'])) { $valueBool = true; } elseif (in_array(strtolower($value), ['false', '0', 'off', 'no'])) { @@ -245,7 +246,7 @@ class ConfigManager { } else { throw new TypeConflictException('Value cannot be converted to boolean'); } - if ($entry?->hasOption(ConfigLexiconEntry::RENAME_INVERT_BOOLEAN) === true) { + if ($entry?->hasOption(Entry::RENAME_INVERT_BOOLEAN) === true) { $valueBool = !$valueBool; } diff --git a/lib/private/Config/Lexicon/CoreConfigLexicon.php b/lib/private/Config/Lexicon/CoreConfigLexicon.php index 34a0b883c54..de84a58131c 100644 --- a/lib/private/Config/Lexicon/CoreConfigLexicon.php +++ b/lib/private/Config/Lexicon/CoreConfigLexicon.php @@ -8,36 +8,36 @@ declare(strict_types=1); namespace OC\Config\Lexicon; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; /** * ConfigLexicon for 'core' app/user configs */ -class CoreConfigLexicon implements IConfigLexicon { - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::IGNORE; +class CoreConfigLexicon implements ILexicon { + public function getStrictness(): Strictness { + return Strictness::IGNORE; } /** * @inheritDoc - * @return ConfigLexiconEntry[] + * @return Entry[] */ public function getAppConfigs(): array { return [ - new ConfigLexiconEntry('lastcron', ValueType::INT, 0, 'timestamp of last cron execution'), + new Entry('lastcron', ValueType::INT, 0, 'timestamp of last cron execution'), ]; } /** * @inheritDoc - * @return ConfigLexiconEntry[] + * @return Entry[] */ public function getUserConfigs(): array { return [ - new ConfigLexiconEntry('lang', ValueType::STRING, null, 'language'), + new Entry('lang', ValueType::STRING, null, 'language'), ]; } } diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index fb0bf954f57..04ba0e29db0 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -11,15 +11,16 @@ namespace OC\Config; use Generator; use InvalidArgumentException; use JsonException; -use NCU\Config\Exceptions\IncorrectTypeException; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\Exceptions\UnknownKeyException; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\Preset; -use NCU\Config\ValueType; use OC\AppFramework\Bootstrap\Coordinator; +use OCP\Config\Exceptions\IncorrectTypeException; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\Exceptions\UnknownKeyException; +use OCP\Config\IUserConfig; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Preset; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; use OCP\DB\Exception as DBException; use OCP\DB\IResult; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -64,7 +65,7 @@ class UserConfig implements IUserConfig { private array $fastLoaded = []; /** @var array ['user_id' => bool] */ private array $lazyLoaded = []; - /** @var array, aliases: array, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ + /** @var array, aliases: array, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; private ?Preset $configLexiconPreset = null; @@ -1913,7 +1914,7 @@ class UserConfig implements IUserConfig { return true; } - /** @var ConfigLexiconEntry $configValue */ + /** @var Entry $configValue */ $configValue = $configDetails['entries'][$key]; if ($type === ValueType::MIXED) { // we overwrite if value was requested as mixed @@ -1954,7 +1955,7 @@ class UserConfig implements IUserConfig { * * The entry is converted to string to fit the expected type when managing default value */ - private function getSystemDefault(string $appId, ConfigLexiconEntry $configValue): ?string { + private function getSystemDefault(string $appId, Entry $configValue): ?string { $default = $this->config->getSystemValue('lexicon.default.userconfig', [])[$appId][$configValue->getKey()] ?? null; if ($default === null) { // no system default, using default default. @@ -1967,28 +1968,28 @@ class UserConfig implements IUserConfig { /** * manage ConfigLexicon behavior based on strictness set in IConfigLexicon * - * @see IConfigLexicon::getStrictness() - * @param ConfigLexiconStrictness|null $strictness + * @param Strictness|null $strictness * @param string $line * * @return bool TRUE if conflict can be fully ignored * @throws UnknownKeyException + *@see ILexicon::getStrictness() */ - private function applyLexiconStrictness(?ConfigLexiconStrictness $strictness, string $line = ''): bool { + private function applyLexiconStrictness(?Strictness $strictness, string $line = ''): bool { if ($strictness === null) { return true; } switch ($strictness) { - case ConfigLexiconStrictness::IGNORE: + case Strictness::IGNORE: return true; - case ConfigLexiconStrictness::NOTICE: + case Strictness::NOTICE: $this->logger->notice($line); return true; - case ConfigLexiconStrictness::WARNING: + case Strictness::WARNING: $this->logger->warning($line); return false; - case ConfigLexiconStrictness::EXCEPTION: + case Strictness::EXCEPTION: throw new UnknownKeyException($line); } @@ -1999,9 +2000,10 @@ class UserConfig implements IUserConfig { * extract details from registered $appId's config lexicon * * @param string $appId - * @internal * - * @return array{entries: array, aliases: array, strictness: ConfigLexiconStrictness} + * @return array{entries: array, aliases: array, strictness: Strictness} + *@internal + * */ public function getConfigDetailsFromLexicon(string $appId): array { if (!array_key_exists($appId, $this->configLexiconDetails)) { @@ -2018,14 +2020,14 @@ class UserConfig implements IUserConfig { $this->configLexiconDetails[$appId] = [ 'entries' => $entries, 'aliases' => $aliases, - 'strictness' => $configLexicon?->getStrictness() ?? ConfigLexiconStrictness::IGNORE + 'strictness' => $configLexicon?->getStrictness() ?? Strictness::IGNORE ]; } return $this->configLexiconDetails[$appId]; } - private function getLexiconEntry(string $appId, string $key): ?ConfigLexiconEntry { + private function getLexiconEntry(string $appId, string $key): ?Entry { return $this->getConfigDetailsFromLexicon($appId)['entries'][$key] ?? null; } diff --git a/lib/private/Server.php b/lib/private/Server.php index 1e1ba2a1ad3..d339a97baab 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -8,7 +8,6 @@ namespace OC; use bantu\IniGetWrapper\IniGetWrapper; -use NCU\Config\IUserConfig; use NCU\Security\Signature\ISignatureManager; use OC\Accounts\AccountManager; use OC\App\AppManager; @@ -139,6 +138,7 @@ use OCP\BackgroundJob\IJobList; use OCP\Collaboration\Reference\IReferenceManager; use OCP\Command\IBus; use OCP\Comments\ICommentsManager; +use OCP\Config\IUserConfig; use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IContactsStore; use OCP\Defaults; @@ -163,7 +163,6 @@ use OCP\Files\Storage\IStorageFactory; use OCP\Files\Template\ITemplateManager; use OCP\FilesMetadata\IFilesMetadataManager; use OCP\FullTextSearch\IFullTextSearchManager; -use OCP\GlobalScale\IConfig; use OCP\Group\ISubAdmin; use OCP\Http\Client\IClientService; use OCP\IAppConfig; diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index 011d1520414..70b35228c87 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -443,7 +443,7 @@ interface IRegistrationContext { * * @param string $configLexiconClass * - * @psalm-param class-string<\NCU\Config\Lexicon\IConfigLexicon> $configLexiconClass + * @psalm-param class-string<\OCP\Config\Lexicon\ILexicon> $configLexiconClass * @since 31.0.0 */ public function registerConfigLexicon(string $configLexiconClass): void; diff --git a/lib/unstable/Config/Exceptions/IncorrectTypeException.php b/lib/public/Config/Exceptions/IncorrectTypeException.php similarity index 80% rename from lib/unstable/Config/Exceptions/IncorrectTypeException.php rename to lib/public/Config/Exceptions/IncorrectTypeException.php index 274c95d732a..33c545c7eea 100644 --- a/lib/unstable/Config/Exceptions/IncorrectTypeException.php +++ b/lib/public/Config/Exceptions/IncorrectTypeException.php @@ -6,12 +6,12 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace NCU\Config\Exceptions; +namespace OCP\Config\Exceptions; use Exception; /** - * @experimental 31.0.0 + * @since 32.0.0 */ class IncorrectTypeException extends Exception { } diff --git a/lib/unstable/Config/Exceptions/TypeConflictException.php b/lib/public/Config/Exceptions/TypeConflictException.php similarity index 80% rename from lib/unstable/Config/Exceptions/TypeConflictException.php rename to lib/public/Config/Exceptions/TypeConflictException.php index c6825b7efcf..4b63bb0a763 100644 --- a/lib/unstable/Config/Exceptions/TypeConflictException.php +++ b/lib/public/Config/Exceptions/TypeConflictException.php @@ -6,12 +6,12 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace NCU\Config\Exceptions; +namespace OCP\Config\Exceptions; use Exception; /** - * @experimental 31.0.0 + * @since 32.0.0 */ class TypeConflictException extends Exception { } diff --git a/lib/unstable/Config/Exceptions/UnknownKeyException.php b/lib/public/Config/Exceptions/UnknownKeyException.php similarity index 80% rename from lib/unstable/Config/Exceptions/UnknownKeyException.php rename to lib/public/Config/Exceptions/UnknownKeyException.php index a3ca88a7b72..39da4d43d95 100644 --- a/lib/unstable/Config/Exceptions/UnknownKeyException.php +++ b/lib/public/Config/Exceptions/UnknownKeyException.php @@ -6,12 +6,12 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace NCU\Config\Exceptions; +namespace OCP\Config\Exceptions; use Exception; /** - * @experimental 31.0.0 + * @since 32.0.0 */ class UnknownKeyException extends Exception { } diff --git a/lib/unstable/Config/IUserConfig.php b/lib/public/Config/IUserConfig.php similarity index 95% rename from lib/unstable/Config/IUserConfig.php rename to lib/public/Config/IUserConfig.php index b9cbb65ad03..050917c85e6 100644 --- a/lib/unstable/Config/IUserConfig.php +++ b/lib/public/Config/IUserConfig.php @@ -6,11 +6,11 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace NCU\Config; +namespace OCP\Config; use Generator; -use NCU\Config\Exceptions\IncorrectTypeException; -use NCU\Config\Exceptions\UnknownKeyException; +use OCP\Config\Exceptions\IncorrectTypeException; +use OCP\Config\Exceptions\UnknownKeyException; /** * This class provides an easy way for apps to store user config in the @@ -27,15 +27,15 @@ use NCU\Config\Exceptions\UnknownKeyException; * lazy loading. Use them wisely and only on parts of the code that are called * during specific requests or actions to avoid loading the lazy values all the time. * - * @experimental 31.0.0 + * @since 32.0.0 */ interface IUserConfig { /** - * @experimental 31.0.0 + * @since 32.0.0 */ public const FLAG_SENSITIVE = 1; // value is sensitive /** - * @experimental 31.0.0 + * @since 32.0.0 */ public const FLAG_INDEXED = 2; // value should be indexed @@ -49,7 +49,7 @@ interface IUserConfig { * * @return list list of userIds * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getUserIds(string $appId = ''): array; @@ -63,7 +63,7 @@ interface IUserConfig { * * @return list list of app ids * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getApps(string $userId): array; @@ -78,7 +78,7 @@ interface IUserConfig { * * @return list list of stored config keys * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getKeys(string $userId, string $app): array; @@ -92,7 +92,7 @@ interface IUserConfig { * * @return bool TRUE if key exists * - * @experimental 31.0.0 + * @since 32.0.0 */ public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool; @@ -107,7 +107,7 @@ interface IUserConfig { * @return bool TRUE if value is sensitive * @throws UnknownKeyException if config key is not known * - * @experimental 31.0.0 + * @since 32.0.0 */ public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool; @@ -127,7 +127,7 @@ interface IUserConfig { * @return bool TRUE if value is sensitive * @throws UnknownKeyException if config key is not known * - * @experimental 31.0.0 + * @since 32.0.0 */ public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool; @@ -144,7 +144,7 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * @see IUserConfig for details about lazy loading * - * @experimental 31.0.0 + * @since 32.0.0 */ public function isLazy(string $userId, string $app, string $key): bool; @@ -161,7 +161,7 @@ interface IUserConfig { * * @return array [key => value] * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getValues(string $userId, string $app, string $prefix = '', bool $filtered = false): array; @@ -176,7 +176,7 @@ interface IUserConfig { * * @return array [key => value] * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getAllValues(string $userId, bool $filtered = false): array; @@ -191,7 +191,7 @@ interface IUserConfig { * * @return array [appId => value] * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getValuesByApps(string $userId, string $key, bool $lazy = false, ?ValueType $typedAs = null): array; @@ -208,7 +208,7 @@ interface IUserConfig { * * @return array [userId => value] * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs = null, ?array $userIds = null): array; @@ -225,7 +225,7 @@ interface IUserConfig { * * @return Generator * - * @experimental 31.0.0 + * @since 32.0.0 */ public function searchUsersByValueString(string $app, string $key, string $value, bool $caseInsensitive = false): Generator; @@ -241,7 +241,7 @@ interface IUserConfig { * * @return Generator * - * @experimental 31.0.0 + * @since 32.0.0 */ public function searchUsersByValueInt(string $app, string $key, int $value): Generator; @@ -257,7 +257,7 @@ interface IUserConfig { * * @return Generator * - * @experimental 31.0.0 + * @since 32.0.0 */ public function searchUsersByValues(string $app, string $key, array $values): Generator; @@ -273,7 +273,7 @@ interface IUserConfig { * * @return Generator * - * @experimental 31.0.0 + * @since 32.0.0 */ public function searchUsersByValueBool(string $app, string $key, bool $value): Generator; @@ -290,7 +290,7 @@ interface IUserConfig { * * @return string stored config value or $default if not set in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see getValueInt() @@ -313,7 +313,7 @@ interface IUserConfig { * * @return int stored config value or $default if not set in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see getValueString() @@ -336,7 +336,7 @@ interface IUserConfig { * * @return float stored config value or $default if not set in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see getValueString() @@ -359,7 +359,7 @@ interface IUserConfig { * * @return bool stored config value or $default if not set in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserPrefences for explanation about lazy loading * @see getValueString() @@ -382,7 +382,7 @@ interface IUserConfig { * * @return array stored config value or $default if not set in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see getValueString() @@ -407,7 +407,7 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * @throws IncorrectTypeException if config value type is not known * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType; @@ -426,7 +426,7 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * @throws IncorrectTypeException if config value type is not known * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int; @@ -447,7 +447,7 @@ interface IUserConfig { * * @return bool TRUE if value was different, therefor updated in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see setValueInt() @@ -479,7 +479,7 @@ interface IUserConfig { * * @return bool TRUE if value was different, therefor updated in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -506,7 +506,7 @@ interface IUserConfig { * * @return bool TRUE if value was different, therefor updated in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -532,7 +532,7 @@ interface IUserConfig { * * @return bool TRUE if value was different, therefor updated in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -559,7 +559,7 @@ interface IUserConfig { * * @return bool TRUE if value was different, therefor updated in database * - * @experimental 31.0.0 + * @since 32.0.0 * * @see IUserConfig for explanation about lazy loading * @see setValueString() @@ -581,7 +581,7 @@ interface IUserConfig { * * @return bool TRUE if database update were necessary * - * @experimental 31.0.0 + * @since 32.0.0 */ public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool; @@ -594,7 +594,7 @@ interface IUserConfig { * @param string $key config key * @param bool $sensitive TRUE to set as sensitive, FALSE to unset * - * @experimental 31.0.0 + * @since 32.0.0 */ public function updateGlobalSensitive(string $app, string $key, bool $sensitive): void; @@ -611,7 +611,7 @@ interface IUserConfig { * * @return bool TRUE if database update were necessary * - * @experimental 31.0.0 + * @since 32.0.0 */ public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool; @@ -624,7 +624,7 @@ interface IUserConfig { * @param string $key config key * @param bool $indexed TRUE to set as indexed, FALSE to unset * - * @experimental 31.0.0 + * @since 32.0.0 */ public function updateGlobalIndexed(string $app, string $key, bool $indexed): void; @@ -638,7 +638,7 @@ interface IUserConfig { * * @return bool TRUE if database update was necessary * - * @experimental 31.0.0 + * @since 32.0.0 */ public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool; @@ -651,7 +651,7 @@ interface IUserConfig { * @param string $key config key * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset * - * @experimental 31.0.0 + * @since 32.0.0 */ public function updateGlobalLazy(string $app, string $key, bool $lazy): void; @@ -677,7 +677,7 @@ interface IUserConfig { * @return array * @throws UnknownKeyException if config key is not known in database * - * @experimental 31.0.0 + * @since 32.0.0 */ public function getDetails(string $userId, string $app, string $key): array; @@ -688,7 +688,7 @@ interface IUserConfig { * @param string $app id of the app * @param string $key config key * - * @experimental 31.0.0 + * @since 32.0.0 */ public function deleteUserConfig(string $userId, string $app, string $key): void; @@ -698,7 +698,7 @@ interface IUserConfig { * @param string $app id of the app * @param string $key config key * - * @experimental 31.0.0 + * @since 32.0.0 */ public function deleteKey(string $app, string $key): void; @@ -707,7 +707,7 @@ interface IUserConfig { * * @param string $app id of the app * - * @experimental 31.0.0 + * @since 32.0.0 */ public function deleteApp(string $app): void; @@ -716,7 +716,7 @@ interface IUserConfig { * * @param string $userId id of the user * - * @experimental 31.0.0 + * @since 32.0.0 */ public function deleteAllUserConfig(string $userId): void; @@ -728,7 +728,7 @@ interface IUserConfig { * @param string $userId id of the user * @param bool $reload set to TRUE to refill cache instantly after clearing it * - * @experimental 31.0.0 + * @since 32.0.0 */ public function clearCache(string $userId, bool $reload = false): void; @@ -736,7 +736,7 @@ interface IUserConfig { * Clear the cache for all users. * The cache will be rebuilt only the next time a user config is requested. * - * @experimental 31.0.0 + * @since 32.0.0 */ public function clearCacheAll(): void; } diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php b/lib/public/Config/Lexicon/Entry.php similarity index 90% rename from lib/unstable/Config/Lexicon/ConfigLexiconEntry.php rename to lib/public/Config/Lexicon/Entry.php index 068d89ce764..95dae44ed11 100644 --- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php +++ b/lib/public/Config/Lexicon/Entry.php @@ -6,19 +6,19 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace NCU\Config\Lexicon; +namespace OCP\Config\Lexicon; use Closure; -use NCU\Config\ValueType; +use OCP\Config\ValueType; /** * Model that represent config values within an app config lexicon. * - * @see IConfigLexicon - * @experimental 31.0.0 + * @see ILexicon + * @since 32.0.0 */ -class ConfigLexiconEntry { - /** @experimental 32.0.0 */ +class Entry { + /** @since 32.0.0 */ public const RENAME_INVERT_BOOLEAN = 1; private string $definition = ''; @@ -33,7 +33,7 @@ class ConfigLexiconEntry { * @param string|null $rename previous config key to migrate config value from * @param bool $deprecated set config key as deprecated * - * @experimental 31.0.0 + * @since 32.0.0 * @psalm-suppress PossiblyInvalidCast * @psalm-suppress RiskyCast */ @@ -63,7 +63,7 @@ class ConfigLexiconEntry { * returns the config key * * @return string config key - * @experimental 31.0.0 + * @since 32.0.0 */ public function getKey(): string { return $this->key; @@ -73,7 +73,7 @@ class ConfigLexiconEntry { * get expected type for config value * * @return ValueType - * @experimental 31.0.0 + * @since 32.0.0 */ public function getValueType(): ValueType { return $this->type; @@ -82,7 +82,7 @@ class ConfigLexiconEntry { /** * @param string $default * @return string - * @experimental 31.0.0 + * @since 32.0.0 */ private function convertFromString(string $default): string { return $default; @@ -91,7 +91,7 @@ class ConfigLexiconEntry { /** * @param int $default * @return string - * @experimental 31.0.0 + * @since 32.0.0 */ private function convertFromInt(int $default): string { return (string)$default; @@ -100,7 +100,7 @@ class ConfigLexiconEntry { /** * @param float $default * @return string - * @experimental 31.0.0 + * @since 32.0.0 */ private function convertFromFloat(float $default): string { return (string)$default; @@ -109,7 +109,7 @@ class ConfigLexiconEntry { /** * @param bool $default * @return string - * @experimental 31.0.0 + * @since 32.0.0 */ private function convertFromBool(bool $default): string { return ($default) ? '1' : '0'; @@ -118,7 +118,7 @@ class ConfigLexiconEntry { /** * @param array $default * @return string - * @experimental 31.0.0 + * @since 32.0.0 */ private function convertFromArray(array $default): string { return json_encode($default); @@ -128,7 +128,7 @@ class ConfigLexiconEntry { * returns default value * * @return string|null NULL if no default is set - * @experimental 31.0.0 + * @since 32.0.0 */ public function getDefault(Preset $preset): ?string { if ($this->default !== null) { @@ -156,7 +156,7 @@ class ConfigLexiconEntry { * @param string|int|float|bool|array $entry * * @return string - * @experimental 31.0.0 + * @since 32.0.0 * @psalm-suppress PossiblyInvalidCast arrays are managed pre-cast * @psalm-suppress RiskyCast */ @@ -180,7 +180,7 @@ class ConfigLexiconEntry { * returns definition * * @return string - * @experimental 31.0.0 + * @since 32.0.0 */ public function getDefinition(): string { return $this->definition; @@ -191,7 +191,7 @@ class ConfigLexiconEntry { * * @see IAppConfig for details on lazy config values * @return bool TRUE if config value is lazy - * @experimental 31.0.0 + * @since 32.0.0 */ public function isLazy(): bool { return $this->lazy; @@ -202,7 +202,7 @@ class ConfigLexiconEntry { * * @see IAppConfig for details on sensitive config values * @return int bitflag about the config value - * @experimental 31.0.0 + * @since 32.0.0 */ public function getFlags(): int { return $this->flags; @@ -212,7 +212,7 @@ class ConfigLexiconEntry { * @param int $flag * * @return bool TRUE is config value bitflag contains $flag - * @experimental 31.0.0 + * @since 32.0.0 */ public function isFlagged(int $flag): bool { return (($flag & $this->getFlags()) === $flag); @@ -223,14 +223,14 @@ class ConfigLexiconEntry { * link to an old config key. * * @return string|null not NULL if value can be imported from a previous key - * @experimental 32.0.0 + * @since 32.0.0 */ public function getRename(): ?string { return $this->rename; } /** - * @experimental 32.0.0 + * @since 32.0.0 * @return bool TRUE if $option was set during the creation of the entry. */ public function hasOption(int $option): bool { @@ -241,7 +241,7 @@ class ConfigLexiconEntry { * returns if config key is set as deprecated * * @return bool TRUE if config si deprecated - * @experimental 31.0.0 + * @since 32.0.0 */ public function isDeprecated(): bool { return $this->deprecated; diff --git a/lib/unstable/Config/Lexicon/IConfigLexicon.php b/lib/public/Config/Lexicon/ILexicon.php similarity index 69% rename from lib/unstable/Config/Lexicon/IConfigLexicon.php rename to lib/public/Config/Lexicon/ILexicon.php index 3fedb5f1f08..b11d09e6789 100644 --- a/lib/unstable/Config/Lexicon/IConfigLexicon.php +++ b/lib/public/Config/Lexicon/ILexicon.php @@ -6,39 +6,39 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-only */ -namespace NCU\Config\Lexicon; +namespace OCP\Config\Lexicon; /** * This interface needs to be implemented if you want to define a config lexicon for your application * The config lexicon is used to avoid conflicts and problems when storing/retrieving config values * - * @experimental 31.0.0 + * @since 32.0.0 */ -interface IConfigLexicon { +interface ILexicon { /** * Define the expected behavior when using config * keys not set within your application config lexicon. * - * @see ConfigLexiconStrictness - * @return ConfigLexiconStrictness - * @experimental 31.0.0 + * @return Strictness + * @since 32.0.0 + *@see Strictness */ - public function getStrictness(): ConfigLexiconStrictness; + public function getStrictness(): Strictness; /** * define the list of entries of your application config lexicon, related to AppConfig. * - * @return ConfigLexiconEntry[] - * @experimental 31.0.0 + * @return Entry[] + * @since 32.0.0 */ public function getAppConfigs(): array; /** * define the list of entries of your application config lexicon, related to UserPreferences. * - * @return ConfigLexiconEntry[] - * @experimental 31.0.0 + * @return Entry[] + * @since 32.0.0 */ public function getUserConfigs(): array; } diff --git a/lib/unstable/Config/Lexicon/Preset.php b/lib/public/Config/Lexicon/Preset.php similarity index 70% rename from lib/unstable/Config/Lexicon/Preset.php rename to lib/public/Config/Lexicon/Preset.php index 92a6fd8cbfa..5199d10568c 100644 --- a/lib/unstable/Config/Lexicon/Preset.php +++ b/lib/public/Config/Lexicon/Preset.php @@ -6,12 +6,12 @@ declare(strict_types=1); * SPDX-License-Identifier: AGPL-3.0-only */ -namespace NCU\Config\Lexicon; +namespace OCP\Config\Lexicon; /** * list of preset to handle the default behavior of the instance * - * @see ConfigLexiconEntry::preset + * @see Entry::preset * * - **Preset::LARGE** - Large size organisation (> 50k accounts) * - **Preset::MEDIUM** - Medium size organisation (> 100 accounts) @@ -22,25 +22,25 @@ namespace NCU\Config\Lexicon; * - **Preset::FAMILY** - Family * - **Preset::PRIVATE** - Private * - * @experimental 32.0.0 + * @since 32.0.0 */ enum Preset: int { - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case LARGE = 8; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case MEDIUM = 7; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case SMALL = 6; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case SHARED = 5; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case EDUCATION = 4; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case CLUB = 3; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case FAMILY = 2; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case PRIVATE = 1; - /** @experimental 32.0.0 */ + /** @since 32.0.0 */ case NONE = 0; } diff --git a/lib/public/Config/Lexicon/Strictness.php b/lib/public/Config/Lexicon/Strictness.php new file mode 100644 index 00000000000..48e96bfc91c --- /dev/null +++ b/lib/public/Config/Lexicon/Strictness.php @@ -0,0 +1,30 @@ +getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_I::APPID, TestConfigLexicon_I::class); - $bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_N::APPID, TestConfigLexicon_N::class); - $bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_W::APPID, TestConfigLexicon_W::class); - $bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_E::APPID, TestConfigLexicon_E::class); + $bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestLexicon_N::APPID, TestLexicon_N::class); + $bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestLexicon_W::APPID, TestLexicon_W::class); + $bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestLexicon_E::APPID, TestLexicon_E::class); $this->appConfig = Server::get(IAppConfig::class); $this->userConfig = Server::get(IUserConfig::class); @@ -51,35 +51,35 @@ class LexiconTest extends TestCase { parent::tearDown(); $this->appConfig->deleteApp(TestConfigLexicon_I::APPID); - $this->appConfig->deleteApp(TestConfigLexicon_N::APPID); - $this->appConfig->deleteApp(TestConfigLexicon_W::APPID); - $this->appConfig->deleteApp(TestConfigLexicon_E::APPID); + $this->appConfig->deleteApp(TestLexicon_N::APPID); + $this->appConfig->deleteApp(TestLexicon_W::APPID); + $this->appConfig->deleteApp(TestLexicon_E::APPID); $this->userConfig->deleteApp(TestConfigLexicon_I::APPID); - $this->userConfig->deleteApp(TestConfigLexicon_N::APPID); - $this->userConfig->deleteApp(TestConfigLexicon_W::APPID); - $this->userConfig->deleteApp(TestConfigLexicon_E::APPID); + $this->userConfig->deleteApp(TestLexicon_N::APPID); + $this->userConfig->deleteApp(TestLexicon_W::APPID); + $this->userConfig->deleteApp(TestLexicon_E::APPID); } public function testAppLexiconSetCorrect() { - $this->assertSame(true, $this->appConfig->setValueString(TestConfigLexicon_E::APPID, 'key1', 'new_value')); - $this->assertSame(true, $this->appConfig->isLazy(TestConfigLexicon_E::APPID, 'key1')); - $this->assertSame(true, $this->appConfig->isSensitive(TestConfigLexicon_E::APPID, 'key1')); - $this->appConfig->deleteKey(TestConfigLexicon_E::APPID, 'key1'); + $this->assertSame(true, $this->appConfig->setValueString(TestLexicon_E::APPID, 'key1', 'new_value')); + $this->assertSame(true, $this->appConfig->isLazy(TestLexicon_E::APPID, 'key1')); + $this->assertSame(true, $this->appConfig->isSensitive(TestLexicon_E::APPID, 'key1')); + $this->appConfig->deleteKey(TestLexicon_E::APPID, 'key1'); } public function testAppLexiconGetCorrect() { - $this->assertSame('abcde', $this->appConfig->getValueString(TestConfigLexicon_E::APPID, 'key1', 'default')); + $this->assertSame('abcde', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key1', 'default')); } public function testAppLexiconSetIncorrectValueType() { $this->expectException(AppConfigTypeConflictException::class); - $this->appConfig->setValueInt(TestConfigLexicon_E::APPID, 'key1', -1); + $this->appConfig->setValueInt(TestLexicon_E::APPID, 'key1', -1); } public function testAppLexiconGetIncorrectValueType() { $this->expectException(AppConfigTypeConflictException::class); - $this->appConfig->getValueInt(TestConfigLexicon_E::APPID, 'key1'); + $this->appConfig->getValueInt(TestLexicon_E::APPID, 'key1'); } public function testAppLexiconIgnore() { @@ -88,45 +88,45 @@ class LexiconTest extends TestCase { } public function testAppLexiconNotice() { - $this->appConfig->setValueString(TestConfigLexicon_N::APPID, 'key_notice', 'new_value'); - $this->assertSame('new_value', $this->appConfig->getValueString(TestConfigLexicon_N::APPID, 'key_notice', '')); + $this->appConfig->setValueString(TestLexicon_N::APPID, 'key_notice', 'new_value'); + $this->assertSame('new_value', $this->appConfig->getValueString(TestLexicon_N::APPID, 'key_notice', '')); } public function testAppLexiconWarning() { - $this->appConfig->setValueString(TestConfigLexicon_W::APPID, 'key_warning', 'new_value'); - $this->assertSame('', $this->appConfig->getValueString(TestConfigLexicon_W::APPID, 'key_warning', '')); + $this->appConfig->setValueString(TestLexicon_W::APPID, 'key_warning', 'new_value'); + $this->assertSame('', $this->appConfig->getValueString(TestLexicon_W::APPID, 'key_warning', '')); } public function testAppLexiconSetException() { $this->expectException(AppConfigUnknownKeyException::class); - $this->appConfig->setValueString(TestConfigLexicon_E::APPID, 'key_exception', 'new_value'); - $this->assertSame('', $this->appConfig->getValueString(TestConfigLexicon_E::APPID, 'key3', '')); + $this->appConfig->setValueString(TestLexicon_E::APPID, 'key_exception', 'new_value'); + $this->assertSame('', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3', '')); } public function testAppLexiconGetException() { $this->expectException(AppConfigUnknownKeyException::class); - $this->appConfig->getValueString(TestConfigLexicon_E::APPID, 'key_exception'); + $this->appConfig->getValueString(TestLexicon_E::APPID, 'key_exception'); } public function testUserLexiconSetCorrect() { - $this->assertSame(true, $this->userConfig->setValueString('user1', TestConfigLexicon_E::APPID, 'key1', 'new_value')); - $this->assertSame(true, $this->userConfig->isLazy('user1', TestConfigLexicon_E::APPID, 'key1')); - $this->assertSame(true, $this->userConfig->isSensitive('user1', TestConfigLexicon_E::APPID, 'key1')); - $this->userConfig->deleteKey(TestConfigLexicon_E::APPID, 'key1'); + $this->assertSame(true, $this->userConfig->setValueString('user1', TestLexicon_E::APPID, 'key1', 'new_value')); + $this->assertSame(true, $this->userConfig->isLazy('user1', TestLexicon_E::APPID, 'key1')); + $this->assertSame(true, $this->userConfig->isSensitive('user1', TestLexicon_E::APPID, 'key1')); + $this->userConfig->deleteKey(TestLexicon_E::APPID, 'key1'); } public function testUserLexiconGetCorrect() { - $this->assertSame('abcde', $this->userConfig->getValueString('user1', TestConfigLexicon_E::APPID, 'key1', 'default')); + $this->assertSame('abcde', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key1', 'default')); } public function testUserLexiconSetIncorrectValueType() { $this->expectException(TypeConflictException::class); - $this->userConfig->setValueInt('user1', TestConfigLexicon_E::APPID, 'key1', -1); + $this->userConfig->setValueInt('user1', TestLexicon_E::APPID, 'key1', -1); } public function testUserLexiconGetIncorrectValueType() { $this->expectException(TypeConflictException::class); - $this->userConfig->getValueInt('user1', TestConfigLexicon_E::APPID, 'key1'); + $this->userConfig->getValueInt('user1', TestLexicon_E::APPID, 'key1'); } public function testUserLexiconIgnore() { @@ -135,24 +135,24 @@ class LexiconTest extends TestCase { } public function testUserLexiconNotice() { - $this->userConfig->setValueString('user1', TestConfigLexicon_N::APPID, 'key_notice', 'new_value'); - $this->assertSame('new_value', $this->userConfig->getValueString('user1', TestConfigLexicon_N::APPID, 'key_notice', '')); + $this->userConfig->setValueString('user1', TestLexicon_N::APPID, 'key_notice', 'new_value'); + $this->assertSame('new_value', $this->userConfig->getValueString('user1', TestLexicon_N::APPID, 'key_notice', '')); } public function testUserLexiconWarning() { - $this->userConfig->setValueString('user1', TestConfigLexicon_W::APPID, 'key_warning', 'new_value'); - $this->assertSame('', $this->userConfig->getValueString('user1', TestConfigLexicon_W::APPID, 'key_warning', '')); + $this->userConfig->setValueString('user1', TestLexicon_W::APPID, 'key_warning', 'new_value'); + $this->assertSame('', $this->userConfig->getValueString('user1', TestLexicon_W::APPID, 'key_warning', '')); } public function testUserLexiconSetException() { $this->expectException(UnknownKeyException::class); - $this->userConfig->setValueString('user1', TestConfigLexicon_E::APPID, 'key_exception', 'new_value'); - $this->assertSame('', $this->userConfig->getValueString('user1', TestConfigLexicon_E::APPID, 'key5', '')); + $this->userConfig->setValueString('user1', TestLexicon_E::APPID, 'key_exception', 'new_value'); + $this->assertSame('', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key5', '')); } public function testUserLexiconGetException() { $this->expectException(UnknownKeyException::class); - $this->userConfig->getValueString('user1', TestConfigLexicon_E::APPID, 'key_exception'); + $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key_exception'); } public function testAppConfigLexiconRenameSetNewValue() { @@ -207,25 +207,25 @@ class LexiconTest extends TestCase { public function testAppConfigLexiconPreset() { $this->configManager->setLexiconPreset(Preset::FAMILY); - $this->assertSame('family', $this->appConfig->getValueString(TestConfigLexicon_E::APPID, 'key3')); + $this->assertSame('family', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3')); } public function testAppConfigLexiconPresets() { $this->configManager->setLexiconPreset(Preset::MEDIUM); - $this->assertSame('club+medium', $this->appConfig->getValueString(TestConfigLexicon_E::APPID, 'key3')); + $this->assertSame('club+medium', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3')); $this->configManager->setLexiconPreset(Preset::FAMILY); - $this->assertSame('family', $this->appConfig->getValueString(TestConfigLexicon_E::APPID, 'key3')); + $this->assertSame('family', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3')); } public function testUserConfigLexiconPreset() { $this->configManager->setLexiconPreset(Preset::FAMILY); - $this->assertSame('family', $this->userConfig->getValueString('user1', TestConfigLexicon_E::APPID, 'key3')); + $this->assertSame('family', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3')); } public function testUserConfigLexiconPresets() { $this->configManager->setLexiconPreset(Preset::MEDIUM); - $this->assertSame('club+medium', $this->userConfig->getValueString('user1', TestConfigLexicon_E::APPID, 'key3')); + $this->assertSame('club+medium', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3')); $this->configManager->setLexiconPreset(Preset::FAMILY); - $this->assertSame('family', $this->userConfig->getValueString('user1', TestConfigLexicon_E::APPID, 'key3')); + $this->assertSame('family', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3')); } } diff --git a/tests/lib/Config/TestConfigLexicon_E.php b/tests/lib/Config/TestConfigLexicon_E.php deleted file mode 100644 index 197c3dc21b1..00000000000 --- a/tests/lib/Config/TestConfigLexicon_E.php +++ /dev/null @@ -1,49 +0,0 @@ - match ($p) { - Preset::FAMILY => 'family', - Preset::CLUB, Preset::MEDIUM => 'club+medium', - default => 'none', - }, 'test key'), - ]; - } - - public function getUserConfigs(): array { - return [ - new ConfigLexiconEntry('key1', ValueType::STRING, 'abcde', 'test key', true, IUserConfig::FLAG_SENSITIVE), - new ConfigLexiconEntry('key2', ValueType::INT, 12345, 'test key', false), - new ConfigLexiconEntry('key3', ValueType::STRING, fn (Preset $p): string => match ($p) { - Preset::FAMILY => 'family', - Preset::CLUB, Preset::MEDIUM => 'club+medium', - default => 'none', - }, 'test key'), - ]; - } -} diff --git a/tests/lib/Config/TestConfigLexicon_I.php b/tests/lib/Config/TestConfigLexicon_I.php index 6fb7921b6e6..077a55bb4fa 100644 --- a/tests/lib/Config/TestConfigLexicon_I.php +++ b/tests/lib/Config/TestConfigLexicon_I.php @@ -8,33 +8,33 @@ declare(strict_types=1); namespace Tests\lib\Config; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\IUserConfig; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; use OCP\IAppConfig; -class TestConfigLexicon_I implements IConfigLexicon { +class TestConfigLexicon_I implements ILexicon { public const APPID = 'lexicon_test_i'; - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::IGNORE; + public function getStrictness(): Strictness { + return Strictness::IGNORE; } public function getAppConfigs(): array { return [ - new ConfigLexiconEntry('key1', ValueType::STRING, 'abcde', 'test key', true, IAppConfig::FLAG_SENSITIVE), - new ConfigLexiconEntry('key2', ValueType::INT, 12345, 'test key', false), - new ConfigLexiconEntry('key3', ValueType::INT, 12345, 'test key', true, rename: 'old_key3'), - new ConfigLexiconEntry('key4', ValueType::BOOL, 12345, 'test key', true, rename: 'old_key4', options: ConfigLexiconEntry::RENAME_INVERT_BOOLEAN), + new Entry('key1', ValueType::STRING, 'abcde', 'test key', true, IAppConfig::FLAG_SENSITIVE), + new Entry('key2', ValueType::INT, 12345, 'test key', false), + new Entry('key3', ValueType::INT, 12345, 'test key', true, rename: 'old_key3'), + new Entry('key4', ValueType::BOOL, 12345, 'test key', true, rename: 'old_key4', options: Entry::RENAME_INVERT_BOOLEAN), ]; } public function getUserConfigs(): array { return [ - new ConfigLexiconEntry('key1', ValueType::STRING, 'abcde', 'test key', true, IUserConfig::FLAG_SENSITIVE), - new ConfigLexiconEntry('key2', ValueType::INT, 12345, 'test key', false) + new Entry('key1', ValueType::STRING, 'abcde', 'test key', true, IUserConfig::FLAG_SENSITIVE), + new Entry('key2', ValueType::INT, 12345, 'test key', false) ]; } diff --git a/tests/lib/Config/TestConfigLexicon_N.php b/tests/lib/Config/TestConfigLexicon_N.php deleted file mode 100644 index 4d96fe9b10d..00000000000 --- a/tests/lib/Config/TestConfigLexicon_N.php +++ /dev/null @@ -1,39 +0,0 @@ - match ($p) { + Preset::FAMILY => 'family', + Preset::CLUB, Preset::MEDIUM => 'club+medium', + default => 'none', + }, 'test key'), + ]; + } + + public function getUserConfigs(): array { + return [ + new Entry('key1', ValueType::STRING, 'abcde', 'test key', true, IUserConfig::FLAG_SENSITIVE), + new Entry('key2', ValueType::INT, 12345, 'test key', false), + new Entry('key3', ValueType::STRING, fn (Preset $p): string => match ($p) { + Preset::FAMILY => 'family', + Preset::CLUB, Preset::MEDIUM => 'club+medium', + default => 'none', + }, 'test key'), + ]; + } +} diff --git a/tests/lib/Config/TestLexicon_N.php b/tests/lib/Config/TestLexicon_N.php new file mode 100644 index 00000000000..87be2149371 --- /dev/null +++ b/tests/lib/Config/TestLexicon_N.php @@ -0,0 +1,39 @@ + Date: Wed, 16 Jul 2025 15:14:18 -0100 Subject: [PATCH 2/5] feat(lexicon): marking unstable as @deprecated Signed-off-by: Maxence Lange --- core/AppInfo/ConfigLexicon.php | 18 +- lib/composer/composer/autoload_classmap.php | 9 + lib/composer/composer/autoload_static.php | 9 + .../Exceptions/IncorrectTypeException.php | 19 + .../Exceptions/TypeConflictException.php | 19 + .../Config/Exceptions/UnknownKeyException.php | 20 + lib/unstable/Config/IUserConfig.php | 831 ++++++++++++++++++ .../Config/Lexicon/ConfigLexiconEntry.php | 297 +++++++ .../Lexicon/ConfigLexiconStrictness.php | 48 + .../Config/Lexicon/IConfigLexicon.php | 55 ++ lib/unstable/Config/Lexicon/Preset.php | 75 ++ lib/unstable/Config/ValueType.php | 143 +++ 12 files changed, 1534 insertions(+), 9 deletions(-) create mode 100644 lib/unstable/Config/Exceptions/IncorrectTypeException.php create mode 100644 lib/unstable/Config/Exceptions/TypeConflictException.php create mode 100644 lib/unstable/Config/Exceptions/UnknownKeyException.php create mode 100644 lib/unstable/Config/IUserConfig.php create mode 100644 lib/unstable/Config/Lexicon/ConfigLexiconEntry.php create mode 100644 lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php create mode 100644 lib/unstable/Config/Lexicon/IConfigLexicon.php create mode 100644 lib/unstable/Config/Lexicon/Preset.php create mode 100644 lib/unstable/Config/ValueType.php diff --git a/core/AppInfo/ConfigLexicon.php b/core/AppInfo/ConfigLexicon.php index cc7fd1a3b09..5dad229267d 100644 --- a/core/AppInfo/ConfigLexicon.php +++ b/core/AppInfo/ConfigLexicon.php @@ -8,31 +8,31 @@ declare(strict_types=1); namespace OC\Core\AppInfo; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; /** * Config Lexicon for core. * * Please Add & Manage your Config Keys in that file and keep the Lexicon up to date! */ -class ConfigLexicon implements IConfigLexicon { +class ConfigLexicon implements ILexicon { public const SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES = 'shareapi_allow_federation_on_public_shares'; - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::IGNORE; + public function getStrictness(): Strictness { + return Strictness::IGNORE; } public function getAppConfigs(): array { return [ - new ConfigLexiconEntry( + new Entry( key: self::SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES, type: ValueType::BOOL, - lazy: true, defaultRaw: true, definition: 'adds share permission to public shares to allow adding them to your Nextcloud (federation)', + lazy: true, ), ]; } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 8586e1e9c31..65c1a299dec 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -7,6 +7,15 @@ $baseDir = dirname(dirname($vendorDir)); return array( 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'NCU\\Config\\Exceptions\\IncorrectTypeException' => $baseDir . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php', + 'NCU\\Config\\Exceptions\\TypeConflictException' => $baseDir . '/lib/unstable/Config/Exceptions/TypeConflictException.php', + 'NCU\\Config\\Exceptions\\UnknownKeyException' => $baseDir . '/lib/unstable/Config/Exceptions/UnknownKeyException.php', + 'NCU\\Config\\IUserConfig' => $baseDir . '/lib/unstable/Config/IUserConfig.php', + 'NCU\\Config\\Lexicon\\ConfigLexiconEntry' => $baseDir . '/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php', + 'NCU\\Config\\Lexicon\\ConfigLexiconStrictness' => $baseDir . '/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php', + 'NCU\\Config\\Lexicon\\IConfigLexicon' => $baseDir . '/lib/unstable/Config/Lexicon/IConfigLexicon.php', + 'NCU\\Config\\Lexicon\\Preset' => $baseDir . '/lib/unstable/Config/Lexicon/Preset.php', + 'NCU\\Config\\ValueType' => $baseDir . '/lib/unstable/Config/ValueType.php', 'NCU\\Federation\\ISignedCloudFederationProvider' => $baseDir . '/lib/unstable/Federation/ISignedCloudFederationProvider.php', 'NCU\\Security\\Signature\\Enum\\DigestAlgorithm' => $baseDir . '/lib/unstable/Security/Signature/Enum/DigestAlgorithm.php', 'NCU\\Security\\Signature\\Enum\\SignatoryStatus' => $baseDir . '/lib/unstable/Security/Signature/Enum/SignatoryStatus.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index d9362634b63..909ac3599f5 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -48,6 +48,15 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 public static $classMap = array ( 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'NCU\\Config\\Exceptions\\IncorrectTypeException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php', + 'NCU\\Config\\Exceptions\\TypeConflictException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/TypeConflictException.php', + 'NCU\\Config\\Exceptions\\UnknownKeyException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/UnknownKeyException.php', + 'NCU\\Config\\IUserConfig' => __DIR__ . '/../../..' . '/lib/unstable/Config/IUserConfig.php', + 'NCU\\Config\\Lexicon\\ConfigLexiconEntry' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php', + 'NCU\\Config\\Lexicon\\ConfigLexiconStrictness' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php', + 'NCU\\Config\\Lexicon\\IConfigLexicon' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/IConfigLexicon.php', + 'NCU\\Config\\Lexicon\\Preset' => __DIR__ . '/../../..' . '/lib/unstable/Config/Lexicon/Preset.php', + 'NCU\\Config\\ValueType' => __DIR__ . '/../../..' . '/lib/unstable/Config/ValueType.php', 'NCU\\Federation\\ISignedCloudFederationProvider' => __DIR__ . '/../../..' . '/lib/unstable/Federation/ISignedCloudFederationProvider.php', 'NCU\\Security\\Signature\\Enum\\DigestAlgorithm' => __DIR__ . '/../../..' . '/lib/unstable/Security/Signature/Enum/DigestAlgorithm.php', 'NCU\\Security\\Signature\\Enum\\SignatoryStatus' => __DIR__ . '/../../..' . '/lib/unstable/Security/Signature/Enum/SignatoryStatus.php', diff --git a/lib/unstable/Config/Exceptions/IncorrectTypeException.php b/lib/unstable/Config/Exceptions/IncorrectTypeException.php new file mode 100644 index 00000000000..b21e1dc1c14 --- /dev/null +++ b/lib/unstable/Config/Exceptions/IncorrectTypeException.php @@ -0,0 +1,19 @@ + list of userIds + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getUserIds(string $appId = ''): array; + + /** + * Get list of all apps that have at least one config + * value related to $userId stored in database + * + * **WARNING:** ignore lazy filtering, all user config are loaded from database + * + * @param string $userId id of the user + * + * @return list list of app ids + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getApps(string $userId): array; + + /** + * Returns all keys stored in database, related to user+app. + * Please note that the values are not returned. + * + * **WARNING:** ignore lazy filtering, all user config are loaded from database + * + * @param string $userId id of the user + * @param string $app id of the app + * + * @return list list of stored config keys + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getKeys(string $userId, string $app): array; + + /** + * Check if a key exists in the list of stored config values. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $lazy search within lazy loaded config + * + * @return bool TRUE if key exists + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool; + + /** + * best way to see if a value is set as sensitive (not displayed in report) + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool|null $lazy search within lazy loaded config + * + * @return bool TRUE if value is sensitive + * @throws UnknownKeyException if config key is not known + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool; + + /** + * best way to see if a value is set as indexed (so it can be search) + * + * @see self::searchUsersByValueString() + * @see self::searchUsersByValueInt() + * @see self::searchUsersByValueBool() + * @see self::searchUsersByValues() + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool|null $lazy search within lazy loaded config + * + * @return bool TRUE if value is sensitive + * @throws UnknownKeyException if config key is not known + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool; + + /** + * Returns if the config key stored in database is lazy loaded + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * + * @return bool TRUE if config is lazy loaded + * @throws UnknownKeyException if config key is not known + * @see IUserConfig for details about lazy loading + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function isLazy(string $userId, string $app, string $key): bool; + + /** + * List all config values from an app with config key starting with $key. + * Returns an array with config key as key, stored value as value. + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $prefix config keys prefix to search, can be empty. + * @param bool $filtered filter sensitive config values + * + * @return array [key => value] + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getValues(string $userId, string $app, string $prefix = '', bool $filtered = false): array; + + /** + * List all config values of a user. + * Returns an array with config key as key, stored value as value. + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * + * @param string $userId id of the user + * @param bool $filtered filter sensitive config values + * + * @return array [key => value] + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getAllValues(string $userId, bool $filtered = false): array; + + /** + * List all apps storing a specific config key and its stored value. + * Returns an array with appId as key, stored value as value. + * + * @param string $userId id of the user + * @param string $key config key + * @param bool $lazy search within lazy loaded config + * @param ValueType|null $typedAs enforce type for the returned values + * + * @return array [appId => value] + * + * @experimental 31.0.0 + * @deprecated 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; + + /** + * List all users storing a specific config key and its stored value. + * Returns an array with userId as key, stored value as value. + * + * **WARNING:** no caching, generate a fresh request + * + * @param string $app id of the app + * @param string $key config key + * @param ValueType|null $typedAs enforce type for the returned values + * @param array|null $userIds limit the search to a list of user ids + * + * @return array [userId => value] + * + * @experimental 31.0.0 + * @deprecated 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; + + /** + * List all users storing a specific config key/value pair. + * Returns a list of user ids. + * + * **WARNING:** no caching, generate a fresh request + * + * @param string $app id of the app + * @param string $key config key + * @param string $value config value + * @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string + * + * @return Generator + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function searchUsersByValueString(string $app, string $key, string $value, bool $caseInsensitive = false): Generator; + + /** + * List all users storing a specific config key/value pair. + * Returns a list of user ids. + * + * **WARNING:** no caching, generate a fresh request + * + * @param string $app id of the app + * @param string $key config key + * @param int $value config value + * + * @return Generator + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function searchUsersByValueInt(string $app, string $key, int $value): Generator; + + /** + * List all users storing a specific config key/value pair. + * Returns a list of user ids. + * + * **WARNING:** no caching, generate a fresh request + * + * @param string $app id of the app + * @param string $key config key + * @param array $values list of possible config values + * + * @return Generator + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function searchUsersByValues(string $app, string $key, array $values): Generator; + + /** + * List all users storing a specific config key/value pair. + * Returns a list of user ids. + * + * **WARNING:** no caching, generate a fresh request + * + * @param string $app id of the app + * @param string $key config key + * @param bool $value config value + * + * @return Generator + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function searchUsersByValueBool(string $app, string $key, bool $value): Generator; + + /** + * Get user config assigned to a config key. + * If config key is not found in database, default value is returned. + * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param string $default default value + * @param bool $lazy search within lazy loaded config + * + * @return string stored config value or $default if not set in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see getValueInt() + * @see getValueFloat() + * @see getValueBool() + * @see getValueArray() + */ + public function getValueString(string $userId, string $app, string $key, string $default = '', bool $lazy = false): string; + + /** + * Get config value assigned to a config key. + * If config key is not found in database, default value is returned. + * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param int $default default value + * @param bool $lazy search within lazy loaded config + * + * @return int stored config value or $default if not set in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see getValueString() + * @see getValueFloat() + * @see getValueBool() + * @see getValueArray() + */ + public function getValueInt(string $userId, string $app, string $key, int $default = 0, bool $lazy = false): int; + + /** + * Get config value assigned to a config key. + * If config key is not found in database, default value is returned. + * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param float $default default value + * @param bool $lazy search within lazy loaded config + * + * @return float stored config value or $default if not set in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see getValueString() + * @see getValueInt() + * @see getValueBool() + * @see getValueArray() + */ + public function getValueFloat(string $userId, string $app, string $key, float $default = 0, bool $lazy = false): float; + + /** + * Get config value assigned to a config key. + * If config key is not found in database, default value is returned. + * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $default default value + * @param bool $lazy search within lazy loaded config + * + * @return bool stored config value or $default if not set in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserPrefences for explanation about lazy loading + * @see getValueString() + * @see getValueInt() + * @see getValueFloat() + * @see getValueArray() + */ + public function getValueBool(string $userId, string $app, string $key, bool $default = false, bool $lazy = false): bool; + + /** + * Get config value assigned to a config key. + * If config key is not found in database, default value is returned. + * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param array $default default value` + * @param bool $lazy search within lazy loaded config + * + * @return array stored config value or $default if not set in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see getValueString() + * @see getValueInt() + * @see getValueFloat() + * @see getValueBool() + */ + public function getValueArray(string $userId, string $app, string $key, array $default = [], bool $lazy = false): array; + + /** + * returns the type of config value + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * unless lazy is set to false + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool|null $lazy + * + * @return ValueType type of the value + * @throws UnknownKeyException if config key is not known + * @throws IncorrectTypeException if config value type is not known + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * @psalm-suppress DeprecatedClass + */ + public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType; + + /** + * returns a bitflag related to config value + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * unless lazy is set to false + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $lazy lazy loading + * + * @return int a bitflag in relation to the config value + * @throws UnknownKeyException if config key is not known + * @throws IncorrectTypeException if config value type is not known + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int; + + /** + * Store a config key and its value in database + * + * If config key is already known with the exact same config value, the database is not updated. + * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded. + * + * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param string $value config value + * @param bool $sensitive if TRUE value will be hidden when listing config values. + * @param bool $lazy set config as lazy loaded + * + * @return bool TRUE if value was different, therefor updated in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see setValueInt() + * @see setValueFloat() + * @see setValueBool() + * @see setValueArray() + */ + public function setValueString(string $userId, string $app, string $key, string $value, bool $lazy = false, int $flags = 0): bool; + + /** + * Store a config key and its value in database + * + * When handling huge value around and/or above 2,147,483,647, a debug log will be generated + * on 64bits system, as php int type reach its limit (and throw an exception) on 32bits when using huge numbers. + * + * When using huge numbers, it is advised to use {@see \OCP\Util::numericToNumber()} and {@see setValueString()} + * + * If config key is already known with the exact same config value, the database is not updated. + * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded. + * + * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param int $value config value + * @param bool $sensitive if TRUE value will be hidden when listing config values. + * @param bool $lazy set config as lazy loaded + * + * @return bool TRUE if value was different, therefor updated in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see setValueString() + * @see setValueFloat() + * @see setValueBool() + * @see setValueArray() + */ + public function setValueInt(string $userId, string $app, string $key, int $value, bool $lazy = false, int $flags = 0): bool; + + /** + * Store a config key and its value in database. + * + * If config key is already known with the exact same config value, the database is not updated. + * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded. + * + * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param float $value config value + * @param bool $sensitive if TRUE value will be hidden when listing config values. + * @param bool $lazy set config as lazy loaded + * + * @return bool TRUE if value was different, therefor updated in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see setValueString() + * @see setValueInt() + * @see setValueBool() + * @see setValueArray() + */ + public function setValueFloat(string $userId, string $app, string $key, float $value, bool $lazy = false, int $flags = 0): bool; + + /** + * Store a config key and its value in database + * + * If config key is already known with the exact same config value, the database is not updated. + * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded. + * + * If config value was previously stored as lazy loaded, status cannot be altered without using {@see deleteKey()} first + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $value config value + * @param bool $lazy set config as lazy loaded + * + * @return bool TRUE if value was different, therefor updated in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see setValueString() + * @see setValueInt() + * @see setValueFloat() + * @see setValueArray() + */ + public function setValueBool(string $userId, string $app, string $key, bool $value, bool $lazy = false): bool; + + /** + * Store a config key and its value in database + * + * If config key is already known with the exact same config value, the database is not updated. + * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded. + * + * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param array $value config value + * @param bool $sensitive if TRUE value will be hidden when listing config values. + * @param bool $lazy set config as lazy loaded + * + * @return bool TRUE if value was different, therefor updated in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + * + * @see IUserConfig for explanation about lazy loading + * @see setValueString() + * @see setValueInt() + * @see setValueFloat() + * @see setValueBool() + */ + public function setValueArray(string $userId, string $app, string $key, array $value, bool $lazy = false, int $flags = 0): bool; + + /** + * switch sensitive status of a config value + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $sensitive TRUE to set as sensitive, FALSE to unset + * + * @return bool TRUE if database update were necessary + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool; + + /** + * switch sensitive loading status of a config key for all users + * + * **Warning:** heavy on resources, MUST only be used on occ command or migrations + * + * @param string $app id of the app + * @param string $key config key + * @param bool $sensitive TRUE to set as sensitive, FALSE to unset + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function updateGlobalSensitive(string $app, string $key, bool $sensitive): void; + + + /** + * switch indexed status of a config value + * + * **WARNING:** ignore lazy filtering, all config values are loaded from database + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $indexed TRUE to set as indexed, FALSE to unset + * + * @return bool TRUE if database update were necessary + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool; + + /** + * switch sensitive loading status of a config key for all users + * + * **Warning:** heavy on resources, MUST only be used on occ command or migrations + * + * @param string $app id of the app + * @param string $key config key + * @param bool $indexed TRUE to set as indexed, FALSE to unset + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function updateGlobalIndexed(string $app, string $key, bool $indexed): void; + + /** + * switch lazy loading status of a config value + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset + * + * @return bool TRUE if database update was necessary + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool; + + /** + * switch lazy loading status of a config key for all users + * + * **Warning:** heavy on resources, MUST only be used on occ command or migrations + * + * @param string $app id of the app + * @param string $key config key + * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function updateGlobalLazy(string $app, string $key, bool $lazy): void; + + /** + * returns an array contains details about a config value + * + * ``` + * [ + * "app" => "myapp", + * "key" => "mykey", + * "value" => "its_value", + * "lazy" => false, + * "type" => 4, + * "typeString" => "string", + * 'sensitive' => true + * ] + * ``` + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * + * @return array + * @throws UnknownKeyException if config key is not known in database + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function getDetails(string $userId, string $app, string $key): array; + + /** + * Delete single config key from database. + * + * @param string $userId id of the user + * @param string $app id of the app + * @param string $key config key + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function deleteUserConfig(string $userId, string $app, string $key): void; + + /** + * Delete config values from all users linked to a specific config keys + * + * @param string $app id of the app + * @param string $key config key + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function deleteKey(string $app, string $key): void; + + /** + * delete all config keys linked to an app + * + * @param string $app id of the app + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function deleteApp(string $app): void; + + /** + * delete all config keys linked to a user + * + * @param string $userId id of the user + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function deleteAllUserConfig(string $userId): void; + + /** + * Clear the cache for a single user + * + * The cache will be rebuilt only the next time a user config is requested. + * + * @param string $userId id of the user + * @param bool $reload set to TRUE to refill cache instantly after clearing it + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\IUserConfig + * @see \OCP\Config\IUserConfig + */ + public function clearCache(string $userId, bool $reload = false): void; + + /** + * Clear the cache for all users. + * The cache will be rebuilt only the next time a user config is requested. + * + * @experimental 31.0.0 + * @deprecated 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 new file mode 100644 index 00000000000..34da89f75b4 --- /dev/null +++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php @@ -0,0 +1,297 @@ +definition = $definition; + } + } + + /** + * returns the config key + * + * @return string config key + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public function getKey(): string { + return $this->key; + } + + /** + * get expected type for config value + * + * @return ValueType + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @psalm-suppress DeprecatedClass + */ + public function getValueType(): ValueType { + return $this->type; + } + + /** + * @param string $default + * @return string + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + private function convertFromString(string $default): string { + return $default; + } + + /** + * @param int $default + * @return string + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + private function convertFromInt(int $default): string { + return (string)$default; + } + + /** + * @param float $default + * @return string + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + private function convertFromFloat(float $default): string { + return (string)$default; + } + + /** + * @param bool $default + * @return string + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + private function convertFromBool(bool $default): string { + return ($default) ? '1' : '0'; + } + + /** + * @param array $default + * @return string + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + private function convertFromArray(array $default): string { + return json_encode($default); + } + + /** + * returns default value + * + * @return string|null NULL if no default is set + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + * @psalm-suppress DeprecatedClass + * @psalm-suppress DeprecatedMethod + */ + public function getDefault(Preset $preset): ?string { + if ($this->default !== null) { + return $this->default; + } + + if ($this->defaultRaw === null) { + return null; + } + + 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; + } + + /** + * convert $entry into string, based on the expected type for config value + * + * @param string|int|float|bool|array $entry + * + * @return string + * @experimental 31.0.0 + * @deprecated 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... + if ($this->getValueType() !== ValueType::ARRAY && is_array($entry)) { + $entry = json_encode($entry, JSON_THROW_ON_ERROR); + } + + return match ($this->getValueType()) { + ValueType::MIXED => (string)$entry, + ValueType::STRING => $this->convertFromString((string)$entry), + ValueType::INT => $this->convertFromInt((int)$entry), + ValueType::FLOAT => $this->convertFromFloat((float)$entry), + ValueType::BOOL => $this->convertFromBool((bool)$entry), + ValueType::ARRAY => $this->convertFromArray((array)$entry) + }; + } + + /** + * returns definition + * + * @return string + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public function getDefinition(): string { + return $this->definition; + } + + /** + * returns if config key is set as lazy + * + * @see IAppConfig for details on lazy config values + * @return bool TRUE if config value is lazy + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public function isLazy(): bool { + return $this->lazy; + } + + /** + * returns flags + * + * @see IAppConfig for details on sensitive config values + * @return int bitflag about the config value + * @experimental 31.0.0 + * @deprecated use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public function getFlags(): int { + return $this->flags; + } + + /** + * @param int $flag + * + * @return bool TRUE is config value bitflag contains $flag + * @experimental 31.0.0 + * @deprecated 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 use \OCP\Config\Lexicon\Entry + * @see \OCP\Config\Lexicon\Entry + */ + public function getRename(): ?string { + return $this->rename; + } + + /** + * @experimental 32.0.0 + * @deprecated 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 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 new file mode 100644 index 00000000000..5da6fca8362 --- /dev/null +++ b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php @@ -0,0 +1,48 @@ + 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 use \OCP\Config\Lexicon\Preset + * @see \OCP\Config\Lexicon\Preset + */ +enum Preset: int { + /** + * @experimental 32.0.0 + * @deprecated + */ + case LARGE = 8; + /** + * @experimental 32.0.0 + * @deprecated + */ + case MEDIUM = 7; + /** + * @experimental 32.0.0 + * @deprecated + */ + case SMALL = 6; + /** + * @experimental 32.0.0 + * @deprecated + */ + case SHARED = 5; + /** + * @experimental 32.0.0 + * @deprecated + */ + case EDUCATION = 4; + /** + * @experimental 32.0.0 + * @deprecated + */ + case CLUB = 3; + /** + * @experimental 32.0.0 + * @deprecated + */ + case FAMILY = 2; + /** + * @experimental 32.0.0 + * @deprecated + */ + case PRIVATE = 1; + /** + * @experimental 32.0.0 + * @deprecated + */ + case NONE = 0; +} diff --git a/lib/unstable/Config/ValueType.php b/lib/unstable/Config/ValueType.php new file mode 100644 index 00000000000..beca7ff34bc --- /dev/null +++ b/lib/unstable/Config/ValueType.php @@ -0,0 +1,143 @@ + self::MIXED, + 'string' => self::STRING, + 'int' => self::INT, + 'float' => self::FLOAT, + 'bool' => self::BOOL, + 'array' => self::ARRAY + }; + } catch (\UnhandledMatchError) { + throw new IncorrectTypeException('unknown string definition'); + } + } + + /** + * get string definition for current enum value + * + * @return string + * @throws IncorrectTypeException + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\ValueType + * @see \OCP\Config\ValueType + * @psalm-suppress DeprecatedConstant + * @psalm-suppress DeprecatedClass + */ + public function getDefinition(): string { + try { + return match ($this) { + self::MIXED => 'mixed', + self::STRING => 'string', + self::INT => 'int', + self::FLOAT => 'float', + self::BOOL => 'bool', + self::ARRAY => 'array', + }; + } catch (UnhandledMatchError) { + throw new IncorrectTypeException('unknown type definition ' . $this->value); + } + } + + /** + * get corresponding AppConfig flag value + * + * @return int + * @throws IncorrectTypeException + * + * @experimental 31.0.0 + * @deprecated use \OCP\Config\ValueType + * @see \OCP\Config\ValueType + * @psalm-suppress DeprecatedConstant + * @psalm-suppress DeprecatedClass + */ + public function toAppConfigFlag(): int { + try { + return match ($this) { + self::MIXED => IAppConfig::VALUE_MIXED, + self::STRING => IAppConfig::VALUE_STRING, + self::INT => IAppConfig::VALUE_INT, + self::FLOAT => IAppConfig::VALUE_FLOAT, + self::BOOL => IAppConfig::VALUE_BOOL, + self::ARRAY => IAppConfig::VALUE_ARRAY, + }; + } catch (UnhandledMatchError) { + throw new IncorrectTypeException('unknown type definition ' . $this->value); + } + } + +} From a0c9fede1bef85d84bef5e9fab30f2069057349f Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 22 Jul 2025 09:38:03 -0100 Subject: [PATCH 3/5] feat(lexicon): marking unstable as @deprecated Signed-off-by: Maxence Lange --- lib/unstable/Config/Exceptions/UnknownKeyException.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/unstable/Config/Exceptions/UnknownKeyException.php b/lib/unstable/Config/Exceptions/UnknownKeyException.php index 9c2d0bbf73b..f519c09a3bc 100644 --- a/lib/unstable/Config/Exceptions/UnknownKeyException.php +++ b/lib/unstable/Config/Exceptions/UnknownKeyException.php @@ -12,7 +12,6 @@ use Exception; /** * @experimental 31.0.0 - * @deprecated * @deprecated use \OCP\Config\Exceptions\UnknownKeyException * @see \OCP\Config\Exceptions\UnknownKeyException */ From f35990421327223ba30007308b141431fc1c42c9 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 24 Jul 2025 13:11:35 -0100 Subject: [PATCH 4/5] fix(lexicon): missing doc Signed-off-by: Maxence Lange --- lib/public/Config/IUserConfig.php | 2 + lib/public/Config/Lexicon/ILexicon.php | 5 ++ .../Exceptions/IncorrectTypeException.php | 2 +- .../Exceptions/TypeConflictException.php | 2 +- .../Config/Exceptions/UnknownKeyException.php | 2 +- lib/unstable/Config/IUserConfig.php | 86 +++++++++---------- .../Config/Lexicon/ConfigLexiconEntry.php | 38 ++++---- .../Lexicon/ConfigLexiconStrictness.php | 10 +-- .../Config/Lexicon/IConfigLexicon.php | 8 +- lib/unstable/Config/Lexicon/Preset.php | 20 ++--- lib/unstable/Config/ValueType.php | 20 ++--- 11 files changed, 101 insertions(+), 94 deletions(-) diff --git a/lib/public/Config/IUserConfig.php b/lib/public/Config/IUserConfig.php index 050917c85e6..1179db2671f 100644 --- a/lib/public/Config/IUserConfig.php +++ b/lib/public/Config/IUserConfig.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OCP\Config; use Generator; +use OCP\AppFramework\Attribute\Consumable; use OCP\Config\Exceptions\IncorrectTypeException; use OCP\Config\Exceptions\UnknownKeyException; @@ -29,6 +30,7 @@ use OCP\Config\Exceptions\UnknownKeyException; * * @since 32.0.0 */ +#[Consumable(since: '32.0.0')] interface IUserConfig { /** * @since 32.0.0 diff --git a/lib/public/Config/Lexicon/ILexicon.php b/lib/public/Config/Lexicon/ILexicon.php index b11d09e6789..1dde23714cb 100644 --- a/lib/public/Config/Lexicon/ILexicon.php +++ b/lib/public/Config/Lexicon/ILexicon.php @@ -8,12 +8,17 @@ declare(strict_types=1); namespace OCP\Config\Lexicon; +use OCP\AppFramework\Attribute\Consumable; +use OCP\AppFramework\Attribute\Implementable; + /** * This interface needs to be implemented if you want to define a config lexicon for your application * The config lexicon is used to avoid conflicts and problems when storing/retrieving config values * * @since 32.0.0 */ +#[Consumable(since: '32.0.0')] +#[Implementable(since: '32.0.0')] interface ILexicon { /** diff --git a/lib/unstable/Config/Exceptions/IncorrectTypeException.php b/lib/unstable/Config/Exceptions/IncorrectTypeException.php index b21e1dc1c14..6b91959071a 100644 --- a/lib/unstable/Config/Exceptions/IncorrectTypeException.php +++ b/lib/unstable/Config/Exceptions/IncorrectTypeException.php @@ -12,7 +12,7 @@ use Exception; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\Exceptions\IncorrectTypeException + * @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 f97e9bca9af..808679ed873 100644 --- a/lib/unstable/Config/Exceptions/TypeConflictException.php +++ b/lib/unstable/Config/Exceptions/TypeConflictException.php @@ -12,7 +12,7 @@ use Exception; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\Exceptions\TypeConflictException + * @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 f519c09a3bc..744ce25e48d 100644 --- a/lib/unstable/Config/Exceptions/UnknownKeyException.php +++ b/lib/unstable/Config/Exceptions/UnknownKeyException.php @@ -12,7 +12,7 @@ use Exception; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\Exceptions\UnknownKeyException + * @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 52bc60289b8..bffd6a96ebd 100644 --- a/lib/unstable/Config/IUserConfig.php +++ b/lib/unstable/Config/IUserConfig.php @@ -28,19 +28,19 @@ use NCU\Config\Exceptions\UnknownKeyException; * during specific requests or actions to avoid loading the lazy values all the time. * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ interface IUserConfig { /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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 use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public const FLAG_INDEXED = 2; // value should be indexed @@ -56,7 +56,7 @@ interface IUserConfig { * @return list list of userIds * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function getUserIds(string $appId = ''): array; @@ -72,7 +72,7 @@ interface IUserConfig { * @return list list of app ids * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function getApps(string $userId): array; @@ -89,7 +89,7 @@ interface IUserConfig { * @return list list of stored config keys * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function getKeys(string $userId, string $app): array; @@ -105,7 +105,7 @@ interface IUserConfig { * @return bool TRUE if key exists * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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; @@ -122,7 +122,7 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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; @@ -144,7 +144,7 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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; @@ -163,7 +163,7 @@ interface IUserConfig { * @see IUserConfig for details about lazy loading * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function isLazy(string $userId, string $app, string $key): bool; @@ -182,7 +182,7 @@ interface IUserConfig { * @return array [key => value] * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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; @@ -199,7 +199,7 @@ interface IUserConfig { * @return array [key => value] * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function getAllValues(string $userId, bool $filtered = false): array; @@ -216,7 +216,7 @@ interface IUserConfig { * @return array [appId => value] * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * @psalm-suppress DeprecatedClass */ @@ -236,7 +236,7 @@ interface IUserConfig { * @return array [userId => value] * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * @psalm-suppress DeprecatedClass */ @@ -256,7 +256,7 @@ interface IUserConfig { * @return Generator * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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; @@ -274,7 +274,7 @@ interface IUserConfig { * @return Generator * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function searchUsersByValueInt(string $app, string $key, int $value): Generator; @@ -292,7 +292,7 @@ interface IUserConfig { * @return Generator * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function searchUsersByValues(string $app, string $key, array $values): Generator; @@ -310,7 +310,7 @@ interface IUserConfig { * @return Generator * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function searchUsersByValueBool(string $app, string $key, bool $value): Generator; @@ -329,7 +329,7 @@ interface IUserConfig { * @return string stored config value or $default if not set in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -354,7 +354,7 @@ interface IUserConfig { * @return int stored config value or $default if not set in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -379,7 +379,7 @@ interface IUserConfig { * @return float stored config value or $default if not set in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -404,7 +404,7 @@ interface IUserConfig { * @return bool stored config value or $default if not set in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserPrefences for explanation about lazy loading @@ -429,7 +429,7 @@ interface IUserConfig { * @return array stored config value or $default if not set in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -456,7 +456,7 @@ interface IUserConfig { * @throws IncorrectTypeException if config value type is not known * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * @psalm-suppress DeprecatedClass */ @@ -478,7 +478,7 @@ interface IUserConfig { * @throws IncorrectTypeException if config value type is not known * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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; @@ -501,7 +501,7 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -535,7 +535,7 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -564,7 +564,7 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -592,7 +592,7 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -621,7 +621,7 @@ interface IUserConfig { * @return bool TRUE if value was different, therefor updated in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig * * @see IUserConfig for explanation about lazy loading @@ -645,7 +645,7 @@ interface IUserConfig { * @return bool TRUE if database update were necessary * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool; @@ -660,7 +660,7 @@ interface IUserConfig { * @param bool $sensitive TRUE to set as sensitive, FALSE to unset * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function updateGlobalSensitive(string $app, string $key, bool $sensitive): void; @@ -679,7 +679,7 @@ interface IUserConfig { * @return bool TRUE if database update were necessary * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool; @@ -694,7 +694,7 @@ interface IUserConfig { * @param bool $indexed TRUE to set as indexed, FALSE to unset * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function updateGlobalIndexed(string $app, string $key, bool $indexed): void; @@ -710,7 +710,7 @@ interface IUserConfig { * @return bool TRUE if database update was necessary * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool; @@ -725,7 +725,7 @@ interface IUserConfig { * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function updateGlobalLazy(string $app, string $key, bool $lazy): void; @@ -753,7 +753,7 @@ interface IUserConfig { * @throws UnknownKeyException if config key is not known in database * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function getDetails(string $userId, string $app, string $key): array; @@ -766,7 +766,7 @@ interface IUserConfig { * @param string $key config key * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function deleteUserConfig(string $userId, string $app, string $key): void; @@ -778,7 +778,7 @@ interface IUserConfig { * @param string $key config key * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function deleteKey(string $app, string $key): void; @@ -789,7 +789,7 @@ interface IUserConfig { * @param string $app id of the app * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function deleteApp(string $app): void; @@ -800,7 +800,7 @@ interface IUserConfig { * @param string $userId id of the user * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function deleteAllUserConfig(string $userId): void; @@ -814,7 +814,7 @@ interface IUserConfig { * @param bool $reload set to TRUE to refill cache instantly after clearing it * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @deprecated 32.0.0 use \OCP\Config\IUserConfig * @see \OCP\Config\IUserConfig */ public function clearCache(string $userId, bool $reload = false): void; @@ -824,7 +824,7 @@ interface IUserConfig { * The cache will be rebuilt only the next time a user config is requested. * * @experimental 31.0.0 - * @deprecated use \OCP\Config\IUserConfig + * @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 34da89f75b4..2587cd52c01 100644 --- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php +++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php @@ -16,14 +16,14 @@ use NCU\Config\ValueType; * * @see IConfigLexicon * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry * @psalm-suppress DeprecatedClass */ class ConfigLexiconEntry { /** * @experimental 32.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public const RENAME_INVERT_BOOLEAN = 1; @@ -41,7 +41,7 @@ class ConfigLexiconEntry { * @param bool $deprecated set config key as deprecated * * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry * @psalm-suppress PossiblyInvalidCast * @psalm-suppress RiskyCast @@ -73,7 +73,7 @@ class ConfigLexiconEntry { * * @return string config key * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public function getKey(): string { @@ -85,7 +85,7 @@ class ConfigLexiconEntry { * * @return ValueType * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry * @psalm-suppress DeprecatedClass */ @@ -97,7 +97,7 @@ class ConfigLexiconEntry { * @param string $default * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ private function convertFromString(string $default): string { @@ -108,7 +108,7 @@ class ConfigLexiconEntry { * @param int $default * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ private function convertFromInt(int $default): string { @@ -119,7 +119,7 @@ class ConfigLexiconEntry { * @param float $default * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ private function convertFromFloat(float $default): string { @@ -130,7 +130,7 @@ class ConfigLexiconEntry { * @param bool $default * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ private function convertFromBool(bool $default): string { @@ -141,7 +141,7 @@ class ConfigLexiconEntry { * @param array $default * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ private function convertFromArray(array $default): string { @@ -153,7 +153,7 @@ class ConfigLexiconEntry { * * @return string|null NULL if no default is set * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry * @psalm-suppress DeprecatedClass * @psalm-suppress DeprecatedMethod @@ -185,7 +185,7 @@ class ConfigLexiconEntry { * * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @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 @@ -214,7 +214,7 @@ class ConfigLexiconEntry { * * @return string * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public function getDefinition(): string { @@ -227,7 +227,7 @@ class ConfigLexiconEntry { * @see IAppConfig for details on lazy config values * @return bool TRUE if config value is lazy * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public function isLazy(): bool { @@ -240,7 +240,7 @@ class ConfigLexiconEntry { * @see IAppConfig for details on sensitive config values * @return int bitflag about the config value * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public function getFlags(): int { @@ -252,7 +252,7 @@ class ConfigLexiconEntry { * * @return bool TRUE is config value bitflag contains $flag * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry * @psalm-suppress DeprecatedMethod */ @@ -266,7 +266,7 @@ class ConfigLexiconEntry { * * @return string|null not NULL if value can be imported from a previous key * @experimental 32.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public function getRename(): ?string { @@ -275,7 +275,7 @@ class ConfigLexiconEntry { /** * @experimental 32.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @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. */ @@ -288,7 +288,7 @@ class ConfigLexiconEntry { * * @return bool TRUE if config si deprecated * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Entry + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry * @see \OCP\Config\Lexicon\Entry */ public function isDeprecated(): bool { diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php index 5da6fca8362..2ccd7bd265c 100644 --- a/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php +++ b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php @@ -17,31 +17,31 @@ namespace NCU\Config\Lexicon; * - **ConfigLexiconStrictness::EXCEPTION** - block (throws exception) and report * * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Strictness + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness * @see \OCP\Config\Lexicon\Strictness */ enum ConfigLexiconStrictness { /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Strictness + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness * @see \OCP\Config\Lexicon\Strictness */ case IGNORE; // fully ignore /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\Strictness + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Strictness * @see \OCP\Config\Lexicon\Strictness */ case NOTICE; // ignore and report /** - * @deprecated use \OCP\Config\Lexicon\Strictness + * @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 - * @deprecated use \OCP\Config\Lexicon\Strictness + * @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 969655d068a..74dc19e7728 100644 --- a/lib/unstable/Config/Lexicon/IConfigLexicon.php +++ b/lib/unstable/Config/Lexicon/IConfigLexicon.php @@ -13,7 +13,7 @@ namespace NCU\Config\Lexicon; * The config lexicon is used to avoid conflicts and problems when storing/retrieving config values * * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\ILexicon + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon * @see \OCP\Config\Lexicon\ILexicon */ interface IConfigLexicon { @@ -24,7 +24,7 @@ interface IConfigLexicon { * * @return ConfigLexiconStrictness * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\ILexicon + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon * @see \OCP\Config\Lexicon\ILexicon * @psalm-suppress DeprecatedClass * @@ -36,7 +36,7 @@ interface IConfigLexicon { * * @return ConfigLexiconEntry[] * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\ILexicon + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon * @see \OCP\Config\Lexicon\ILexicon * @psalm-suppress DeprecatedClass */ @@ -47,7 +47,7 @@ interface IConfigLexicon { * * @return ConfigLexiconEntry[] * @experimental 31.0.0 - * @deprecated use \OCP\Config\Lexicon\ILexicon + * @deprecated 32.0.0 use \OCP\Config\Lexicon\ILexicon * @see \OCP\Config\Lexicon\ILexicon * @psalm-suppress DeprecatedClass */ diff --git a/lib/unstable/Config/Lexicon/Preset.php b/lib/unstable/Config/Lexicon/Preset.php index fb50756c535..b2a98ed5647 100644 --- a/lib/unstable/Config/Lexicon/Preset.php +++ b/lib/unstable/Config/Lexicon/Preset.php @@ -23,53 +23,53 @@ namespace NCU\Config\Lexicon; * - **Preset::PRIVATE** - Private * * @experimental 32.0.0 - * @deprecated use \OCP\Config\Lexicon\Preset + * @deprecated 32.0.0 use \OCP\Config\Lexicon\Preset * @see \OCP\Config\Lexicon\Preset */ enum Preset: int { /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case LARGE = 8; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case MEDIUM = 7; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case SMALL = 6; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case SHARED = 5; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case EDUCATION = 4; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case CLUB = 3; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case FAMILY = 2; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case PRIVATE = 1; /** * @experimental 32.0.0 - * @deprecated + * @deprecated 32.0.0 */ case NONE = 0; } diff --git a/lib/unstable/Config/ValueType.php b/lib/unstable/Config/ValueType.php index beca7ff34bc..73714640445 100644 --- a/lib/unstable/Config/ValueType.php +++ b/lib/unstable/Config/ValueType.php @@ -16,43 +16,43 @@ use UnhandledMatchError; * Listing of available value type for typed config value * * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ enum ValueType: int { /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ case MIXED = 0; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ case STRING = 1; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ case INT = 2; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ case FLOAT = 3; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ case BOOL = 4; /** * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType */ case ARRAY = 5; @@ -66,7 +66,7 @@ enum ValueType: int { * @throws IncorrectTypeException * * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType * @psalm-suppress DeprecatedConstant * @psalm-suppress DeprecatedClass @@ -93,7 +93,7 @@ enum ValueType: int { * @throws IncorrectTypeException * * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType * @psalm-suppress DeprecatedConstant * @psalm-suppress DeprecatedClass @@ -120,7 +120,7 @@ enum ValueType: int { * @throws IncorrectTypeException * * @experimental 31.0.0 - * @deprecated use \OCP\Config\ValueType + * @deprecated 32.0.0 use \OCP\Config\ValueType * @see \OCP\Config\ValueType * @psalm-suppress DeprecatedConstant * @psalm-suppress DeprecatedClass From 011500fc7c3db3707b709c0641e170bd29b0da37 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 24 Jul 2025 15:56:07 -0100 Subject: [PATCH 5/5] feat(preset): split education based on size Signed-off-by: Maxence Lange --- lib/public/Config/Lexicon/Preset.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/public/Config/Lexicon/Preset.php b/lib/public/Config/Lexicon/Preset.php index 5199d10568c..ba0fb66dd3b 100644 --- a/lib/public/Config/Lexicon/Preset.php +++ b/lib/public/Config/Lexicon/Preset.php @@ -17,7 +17,8 @@ namespace OCP\Config\Lexicon; * - **Preset::MEDIUM** - Medium size organisation (> 100 accounts) * - **Preset::SMALL** - Small size organisation (< 100 accounts) * - **Preset::SHARED** - Shared hosting - * - **Preset::EDUCATION** - School/University + * - **Preset::UNIVERSITY** - Education, large size + * - **Preset::SCHOOL** - Eduction, small/medium size * - **Preset::CLUB** - Club/Association * - **Preset::FAMILY** - Family * - **Preset::PRIVATE** - Private @@ -26,15 +27,17 @@ namespace OCP\Config\Lexicon; */ enum Preset: int { /** @since 32.0.0 */ - case LARGE = 8; + case LARGE = 9; /** @since 32.0.0 */ - case MEDIUM = 7; + case MEDIUM = 8; /** @since 32.0.0 */ - case SMALL = 6; + case SMALL = 7; /** @since 32.0.0 */ - case SHARED = 5; + case SHARED = 6; /** @since 32.0.0 */ - case EDUCATION = 4; + case UNIVERSITY = 5; + /** @since 32.0.0 */ + case SCHOOL = 4; /** @since 32.0.0 */ case CLUB = 3; /** @since 32.0.0 */