refactor: ValueKind enum instead of kind string literals (L1)
enum ValueKind: string { Html, Code, Url, Text } with strictness() and
tightens(self $routed) (the S33a rule formerly AttrWriter/ValueCleaner::tightens
over STRICTNESS). ValueCleaner::clean() takes ?ValueKind, kindOf()/kind()/
unknownKind() return it, the sanitizer match is exhaustive over the four cases;
the "Feldart" message prints ->value, so its text is unchanged. ShortformWriter
drops the identity map CLEAN_KIND for ValueKind::tryFrom($spec['kind']) ??
ValueKind::Text; Composer and ShortformWriter pass ValueKind::Text/Url.
The installed PHPCompatibility sniffs do not know enums: two sniffs are disabled
in ValueKind.php only, with the reason.
Tests: ValueCleanerTest passes/asserts ValueKind cases instead of strings;
+ValueKindTest (full tightens matrix, case values).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -503,7 +503,7 @@ final class Composer
|
||||
}
|
||||
|
||||
try {
|
||||
$clean = $this->cleaner->clean($name, self::LABEL_PATH, $label, null, 'text');
|
||||
$clean = $this->cleaner->clean($name, self::LABEL_PATH, $label, null, ValueKind::Text);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->errors[$path] = $e->getMessage();
|
||||
|
||||
@@ -553,7 +553,7 @@ final class Composer
|
||||
|
||||
// Design-system data, but still through the choke point: an id text() would change is refused.
|
||||
try {
|
||||
$clean = $this->cleaner->clean($name, 'modulePreset', $id, null, 'text');
|
||||
$clean = $this->cleaner->clean($name, 'modulePreset', $id, null, ValueKind::Text);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$clean = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user