Skip to content

Commit

Permalink
fix(lexicon): renaming and minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Dec 12, 2024
1 parent cafa3eb commit bf0b199
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ private function getTypedValue(
int $type,
): string {
$this->assertParams($app, $key, valueType: $type);
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, $default)) {
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $default)) {
return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
}
$this->loadConfig($app, $lazy);
Expand Down Expand Up @@ -730,7 +730,7 @@ private function setTypedValue(
int $type,
): bool {
$this->assertParams($app, $key);
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type)) {
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type)) {
return false; // returns false as database is not updated
}
$this->loadConfig(null, $lazy);
Expand Down Expand Up @@ -1573,13 +1573,13 @@ public function clearCachedConfig(): void {
}

/**
* verify and compare current use of config values with defined lexicon
* match and apply current use of config values with defined lexicon
*
* @throws AppConfigUnknownKeyException
* @throws AppConfigTypeConflictException
* @return bool TRUE if everything is fine compared to lexicon or lexicon does not exist
*/
private function compareRegisteredConfigValues(
private function matchAndApplyLexiconDefinition(
string $app,
string $key,
bool &$lazy,
Expand Down
10 changes: 5 additions & 5 deletions lib/private/Config/UserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ private function getTypedValue(
ValueType $type,
): string {
$this->assertParams($userId, $app, $key);
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, default: $default)) {
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, default: $default)) {
return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
}
$this->loadConfig($userId, $lazy);
Expand Down Expand Up @@ -1046,7 +1046,7 @@ private function setTypedValue(
ValueType $type,
): bool {
$this->assertParams($userId, $app, $key);
if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, $flags)) {
if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $flags)) {
return false; // returns false as database is not updated
}
$this->loadConfig($userId, $lazy);
Expand Down Expand Up @@ -1816,12 +1816,12 @@ private function decryptSensitiveValue(string $userId, string $app, string $key,
}

/**
* verify and compare current use of config values with defined lexicon
* match and apply current use of config values with defined lexicon
*
* @throws UnknownKeyException
* @throws TypeConflictException
*/
private function compareRegisteredConfigValues(
private function matchAndApplyLexiconDefinition(
string $app,
string $key,
bool &$lazy,
Expand All @@ -1837,7 +1837,7 @@ private function compareRegisteredConfigValues(
/** @var ConfigLexiconEntry $configValue */
$configValue = $configDetails['entries'][$key];
if ($type === ValueType::MIXED) {
$type = $configValue->getValueType()->value; // we overwrite if value was requested as mixed
$type = $configValue->getValueType(); // we overwrite if value was requested as mixed
} elseif ($configValue->getValueType() !== $type) {
throw new TypeConflictException('The user config key ' . $app . '/' . $key . ' is typed incorrectly in relation to the config lexicon');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getFlags(): int {
* @experimental 31.0.0
*/
public function isFlagged(int $flag): bool {
return (bool)($flag & $this->getFlags());
return (($flag & $this->getFlags()) === $flag);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*
* @experimental 31.0.0
*/
enum ConfigLexiconStrictness: int {
enum ConfigLexiconStrictness {
/** @experimental 31.0.0 */
case IGNORE = 0; // fully ignore
case IGNORE; // fully ignore
/** @experimental 31.0.0 */
case NOTICE = 2; // ignore and report
case NOTICE; // ignore and report
/** @experimental 31.0.0 */
case WARNING = 3; // silently block (returns $default) and report
case WARNING; // silently block (returns $default) and report
/** @experimental 31.0.0 */
case EXCEPTION = 5; // block (throws exception) and report
case EXCEPTION; // block (throws exception) and report
}

0 comments on commit bf0b199

Please sign in to comment.