From 9f6f83c479985e882dbd086a8495bcd772c80b54 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Jun 2026 11:12:39 +0900 Subject: fix(array-merge): route mixed-key merges through faithful array_merge * Config::merge called array_merge_recursive where PHP uses plain array_merge (string-key overwrite); switch those six sites to array_merge. * provides/replaces merges that may carry an AliasPackage's self.version numeric keys ("0","1",...) were collapsing under naive chain/insert/or_insert; route them through a new array_merge_map(). Co-Authored-By: Claude Opus 4.8 --- .../src/command/check_platform_reqs_command.rs | 43 +++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'crates/shirabe/src/command/check_platform_reqs_command.rs') diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs index 14b3be2..5225f7e 100644 --- a/crates/shirabe/src/command/check_platform_reqs_command.rs +++ b/crates/shirabe/src/command/check_platform_reqs_command.rs @@ -4,7 +4,7 @@ use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::component::console::input::InputInterface; use shirabe_external_packages::symfony::component::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, strip_tags}; +use shirabe_php_shim::{PhpMixed, array_merge_map, strip_tags}; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; @@ -153,28 +153,27 @@ impl CheckPlatformReqsCommand { if !candidates.is_empty() { let mut req_results: Vec = vec![]; 'candidates: for candidate in &candidates { - let candidate_constraint: Option = - if candidate.get_name() == *require { - let c = SimpleConstraint::new( - "=".to_string(), - candidate.get_version().to_string(), - Some(candidate.get_pretty_version().to_string()), - ); - Some(c.into()) - } else { - let mut found: Option = None; - for (_, link) in candidate - .get_provides() - .iter() - .chain(candidate.get_replaces().iter()) - { - if link.get_target() == require { - found = Some(link.get_constraint().clone()); - break; - } + let candidate_constraint: Option = if candidate.get_name() + == *require + { + let c = SimpleConstraint::new( + "=".to_string(), + candidate.get_version().to_string(), + Some(candidate.get_pretty_version().to_string()), + ); + Some(c.into()) + } else { + let mut found: Option = None; + let provides_and_replaces = + array_merge_map(candidate.get_provides(), candidate.get_replaces()); + for (_, link) in &provides_and_replaces { + if link.get_target() == require { + found = Some(link.get_constraint().clone()); + break; } - found - }; + } + found + }; let candidate_constraint = match candidate_constraint { Some(c) => c, -- cgit v1.3.1