aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package/loader
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 17:02:11 +0900
committernsfisis <nsfisis@gmail.com>2026-06-26 00:20:05 +0900
commit3498bb1ca00ab7d051d296b8d482bea987a00fa4 (patch)
treee10260e5816317f4547847e2a230ea1a87fb2448 /crates/shirabe/src/package/loader
parent291b43d132749a61918dca23acef1b639c5333a7 (diff)
downloadphp-shirabe-3498bb1ca00ab7d051d296b8d482bea987a00fa4.tar.gz
php-shirabe-3498bb1ca00ab7d051d296b8d482bea987a00fa4.tar.zst
php-shirabe-3498bb1ca00ab7d051d296b8d482bea987a00fa4.zip
test: port 24 command/repository/package/util tests; add TlsHelper
Port command (9), util gitlab/forgejo/tls (6), package (6), repository (3) tests. Implement TlsHelper. Fix porting bugs: config_command extra merge, RootAliasPackage setters, ValidatingArrayLoader isset, repository_factory name generation, forgejo exception code, version_parser error chaining. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/loader')
-rw-r--r--crates/shirabe/src/package/loader/validating_array_loader.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs
index 342e1cb..6a85e37 100644
--- a/crates/shirabe/src/package/loader/validating_array_loader.rs
+++ b/crates/shirabe/src/package/loader/validating_array_loader.rs
@@ -1063,19 +1063,22 @@ impl ValidatingArrayLoader {
.and_then(|v| v.as_array())
.cloned()
.unwrap_or_default();
- if !section.contains_key("type") {
+ // Mirror PHP `isset()`, which is false for both missing keys and null values.
+ let isset =
+ |key: &str| matches!(section.get(key), Some(v) if !matches!(v, PhpMixed::Null));
+ if !isset("type") {
self.errors
.push(format!("{}.type : must be present", src_type));
}
- if !section.contains_key("url") {
+ if !isset("url") {
self.errors
.push(format!("{}.url : must be present", src_type));
}
- if src_type == "source" && !section.contains_key("reference") {
+ if src_type == "source" && !isset("reference") {
self.errors
.push(format!("{}.reference : must be present", src_type));
}
- if let Some(type_val) = section.get("type")
+ if let Some(type_val) = section.get("type").filter(|_| isset("type"))
&& !is_string(type_val)
{
self.errors.push(format!(
@@ -1084,7 +1087,7 @@ impl ValidatingArrayLoader {
get_debug_type(type_val)
));
}
- if let Some(url_val) = section.get("url")
+ if let Some(url_val) = section.get("url").filter(|_| isset("url"))
&& !is_string(url_val)
{
self.errors.push(format!(
@@ -1093,7 +1096,7 @@ impl ValidatingArrayLoader {
get_debug_type(url_val)
));
}
- if let Some(ref_val) = section.get("reference")
+ if let Some(ref_val) = section.get("reference").filter(|_| isset("reference"))
&& !is_string(ref_val)
&& !is_int(ref_val)
{
@@ -1103,7 +1106,7 @@ impl ValidatingArrayLoader {
get_debug_type(ref_val)
));
}
- if let Some(ref_val) = section.get("reference") {
+ if let Some(ref_val) = section.get("reference").filter(|_| isset("reference")) {
let ref_str = php_to_string(ref_val);
if Preg::is_match("{^\\s*-}", &ref_str) {
self.errors.push(format!(
@@ -1112,7 +1115,7 @@ impl ValidatingArrayLoader {
));
}
}
- if let Some(url_val) = section.get("url") {
+ if let Some(url_val) = section.get("url").filter(|_| isset("url")) {
let url_str = php_to_string(url_val);
if Preg::is_match("{^\\s*-}", &url_str) {
self.errors.push(format!(