From 1e7aabcae1b2139aa20a80fbf303c74388933f55 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Jun 2026 15:16:07 +0900 Subject: fix(array-dumper): emit package links and require Link pretty constraint Resolve the phase-b TODO that left the supported-link-types loop as dead code (links were always an empty Vec), so requires/conflicts/provides/ replaces/require-dev are dumped again via PackageInterface::get_links_for_type, matching the PHP magic-call loop. Every Link in production is constructed with a pretty constraint (all ArrayLoader/AliasPackage/PlatformRepository/InstalledRepository sites pass one), so make Link::pretty_constraint a required String instead of Option. get_pretty_constraint() now returns &str directly rather than anyhow::Result<&str>, dropping the unreachable UnexpectedValueException guard, and all call sites are updated. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/package/link.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'crates/shirabe/src/package/link.rs') diff --git a/crates/shirabe/src/package/link.rs b/crates/shirabe/src/package/link.rs index 13bd66b..ab1e9c6 100644 --- a/crates/shirabe/src/package/link.rs +++ b/crates/shirabe/src/package/link.rs @@ -1,6 +1,5 @@ //! ref: composer/src/Composer/Package/Link.php -use shirabe_php_shim::UnexpectedValueException; use shirabe_semver::constraint::AnyConstraint; use crate::package::PackageInterfaceHandle; @@ -10,7 +9,7 @@ pub struct Link { pub(crate) target: String, pub(crate) constraint: AnyConstraint, pub(crate) description: String, - pub(crate) pretty_constraint: Option, + pub(crate) pretty_constraint: String, } impl Clone for Link { @@ -65,7 +64,7 @@ impl Link { target: String, constraint: AnyConstraint, description: Option, - pretty_constraint: Option, + pretty_constraint: String, ) -> Self { let description = description.unwrap_or_else(|| Self::TYPE_UNKNOWN.to_string()); let description = if description == Self::TYPE_DEV_REQUIRE { @@ -98,17 +97,8 @@ impl Link { &self.constraint } - pub fn get_pretty_constraint(&self) -> anyhow::Result<&str> { - match &self.pretty_constraint { - None => Err(anyhow::anyhow!(UnexpectedValueException { - message: format!( - "Link {} has been misconfigured and had no prettyConstraint given.", - self.to_string() - ), - code: 0, - })), - Some(s) => Ok(s.as_str()), - } + pub fn get_pretty_constraint(&self) -> &str { + &self.pretty_constraint } pub fn to_string(&self) -> String { -- cgit v1.3.1