mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Fix ConfigValidator and sort config
This commit is contained in:
parent
33d587ee9e
commit
451de4a6f6
@ -555,12 +555,6 @@
|
||||
"libuv.a"
|
||||
]
|
||||
},
|
||||
"re2c": {
|
||||
"source": "re2c",
|
||||
"bin-unix": [
|
||||
"re2c"
|
||||
]
|
||||
},
|
||||
"libwebp": {
|
||||
"source": "libwebp",
|
||||
"pkg-configs": [
|
||||
@ -803,6 +797,12 @@
|
||||
"depot.h"
|
||||
]
|
||||
},
|
||||
"re2c": {
|
||||
"source": "re2c",
|
||||
"bin-unix": [
|
||||
"re2c"
|
||||
]
|
||||
},
|
||||
"readline": {
|
||||
"source": "readline",
|
||||
"static-libs-unix": [
|
||||
|
||||
@ -932,6 +932,20 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"re2c": {
|
||||
"type": "ghrel",
|
||||
"repo": "skvadrik/re2c",
|
||||
"match": "re2c.+\\.tar\\.xz",
|
||||
"prefer-stable": true,
|
||||
"alt": {
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz"
|
||||
},
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"readline": {
|
||||
"type": "filelist",
|
||||
"url": "https://ftp.gnu.org/pub/gnu/readline/",
|
||||
@ -1112,20 +1126,6 @@
|
||||
"text": "(C) 1995-2022 Jean-loup Gailly and Mark Adler\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n claim that you wrote the original software. If you use this software\n in a product, an acknowledgment in the product documentation would be\n appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\n misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n\nJean-loup Gailly Mark Adler\njloup@gzip.org madler@alumni.caltech.edu"
|
||||
}
|
||||
},
|
||||
"re2c": {
|
||||
"type": "ghrel",
|
||||
"repo": "skvadrik/re2c",
|
||||
"match": "re2c.+\\.tar\\.xz",
|
||||
"prefer-stable": true,
|
||||
"alt": {
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz"
|
||||
},
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"zstd": {
|
||||
"type": "ghrel",
|
||||
"repo": "facebook/zstd",
|
||||
|
||||
@ -47,25 +47,50 @@ class ConfigValidator
|
||||
|
||||
// check if license is valid
|
||||
if (isset($src['license'])) {
|
||||
if (!is_assoc_array($src['license'])) {
|
||||
throw new ValidationException("source {$name} license must be object");
|
||||
if (!is_array($src['license'])) {
|
||||
throw new ValidationException("source {$name} license must be an object or array");
|
||||
}
|
||||
if (!isset($src['license']['type'])) {
|
||||
throw new ValidationException("source {$name} license must have type");
|
||||
}
|
||||
if (!in_array($src['license']['type'], ['file', 'text'])) {
|
||||
throw new ValidationException("source {$name} license type is invalid");
|
||||
}
|
||||
if ($src['license']['type'] === 'file' && !isset($src['license']['path'])) {
|
||||
throw new ValidationException("source {$name} license file must have path");
|
||||
}
|
||||
if ($src['license']['type'] === 'text' && !isset($src['license']['text'])) {
|
||||
throw new ValidationException("source {$name} license text must have text");
|
||||
if (is_assoc_array($src['license'])) {
|
||||
self::checkSingleLicense($src['license'], $name);
|
||||
} elseif (is_list_array($src['license'])) {
|
||||
foreach ($src['license'] as $license) {
|
||||
if (!is_assoc_array($license)) {
|
||||
throw new ValidationException("source {$name} license must be an object or array");
|
||||
}
|
||||
self::checkSingleLicense($license, $name);
|
||||
}
|
||||
} else {
|
||||
throw new ValidationException("source {$name} license must be an object or array");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user