This commit is contained in:
crazywhalecc 2025-08-01 02:05:46 +08:00
parent 6b23f4b34a
commit 7d0577460f
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680

View File

@ -66,31 +66,6 @@ class ConfigValidator
}
}
/**
* @throws ValidationException
*/
private static function checkSingleLicense(array $license, string $name): void
{
if (!is_assoc_array($license)) {
throw new ValidationException("source {$name} license must be an object");
}
if (!isset($license['type'])) {
throw new ValidationException("source {$name} license must have type");
}
if (!in_array($license['type'], ['file', 'text'])) {
throw new ValidationException("source {$name} license type is invalid");
}
if (!in_array($license['type'], ['file', 'text'])) {
throw new ValidationException("source {$name} license type is invalid");
}
if ($license['type'] === 'file' && !isset($license['path'])) {
throw new ValidationException("source {$name} license file must have path");
}
if ($license['type'] === 'text' && !isset($license['text'])) {
throw new ValidationException("source {$name} license text must have text");
}
}
/**
* @throws ValidationException
*/
@ -440,6 +415,31 @@ class ConfigValidator
return $craft;
}
/**
* @throws ValidationException
*/
private static function checkSingleLicense(array $license, string $name): void
{
if (!is_assoc_array($license)) {
throw new ValidationException("source {$name} license must be an object");
}
if (!isset($license['type'])) {
throw new ValidationException("source {$name} license must have type");
}
if (!in_array($license['type'], ['file', 'text'])) {
throw new ValidationException("source {$name} license type is invalid");
}
if (!in_array($license['type'], ['file', 'text'])) {
throw new ValidationException("source {$name} license type is invalid");
}
if ($license['type'] === 'file' && !isset($license['path'])) {
throw new ValidationException("source {$name} license file must have path");
}
if ($license['type'] === 'text' && !isset($license['text'])) {
throw new ValidationException("source {$name} license text must have text");
}
}
/**
* Validate source type configuration (shared between source.json and pkg.json)
*