aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/package')
-rw-r--r--crates/shirabe/src/package/loader/validating_array_loader.rs19
-rw-r--r--crates/shirabe/src/package/root_alias_package.rs17
2 files changed, 28 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!(
diff --git a/crates/shirabe/src/package/root_alias_package.rs b/crates/shirabe/src/package/root_alias_package.rs
index 140c96d..4d8bd6e 100644
--- a/crates/shirabe/src/package/root_alias_package.rs
+++ b/crates/shirabe/src/package/root_alias_package.rs
@@ -92,18 +92,35 @@ impl RootPackageInterface for RootAliasPackage {
}
fn set_dev_requires(&mut self, dev_requires: IndexMap<String, Link>) {
+ self.inner.inner.dev_requires = self
+ .inner
+ .inner
+ .replace_self_version_dependencies(dev_requires.clone(), Link::TYPE_DEV_REQUIRE);
+
self.alias_of.set_dev_requires(dev_requires);
}
fn set_conflicts(&mut self, conflicts: IndexMap<String, Link>) {
+ self.inner.inner.conflicts = self
+ .inner
+ .inner
+ .replace_self_version_dependencies(conflicts.clone(), Link::TYPE_CONFLICT);
self.alias_of.set_conflicts(conflicts);
}
fn set_provides(&mut self, provides: IndexMap<String, Link>) {
+ self.inner.inner.provides = self
+ .inner
+ .inner
+ .replace_self_version_dependencies(provides.clone(), Link::TYPE_PROVIDE);
self.alias_of.set_provides(provides);
}
fn set_replaces(&mut self, replaces: IndexMap<String, Link>) {
+ self.inner.inner.replaces = self
+ .inner
+ .inner
+ .replace_self_version_dependencies(replaces.clone(), Link::TYPE_REPLACE);
self.alias_of.set_replaces(replaces);
}