diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-06 15:16:07 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-06 15:17:00 +0900 |
| commit | 1e7aabcae1b2139aa20a80fbf303c74388933f55 (patch) | |
| tree | 07c5f4e7502841fef21909b2aa8269e6e71fb2a3 /crates/shirabe/src/package/dumper/array_dumper.rs | |
| parent | adba8b1969a3f40245324d7feb5905693ca65d5e (diff) | |
| download | php-shirabe-1e7aabcae1b2139aa20a80fbf303c74388933f55.tar.gz php-shirabe-1e7aabcae1b2139aa20a80fbf303c74388933f55.tar.zst php-shirabe-1e7aabcae1b2139aa20a80fbf303c74388933f55.zip | |
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<String>. 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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/dumper/array_dumper.rs')
| -rw-r--r-- | crates/shirabe/src/package/dumper/array_dumper.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/crates/shirabe/src/package/dumper/array_dumper.rs b/crates/shirabe/src/package/dumper/array_dumper.rs index 6a693bd..4217308 100644 --- a/crates/shirabe/src/package/dumper/array_dumper.rs +++ b/crates/shirabe/src/package/dumper/array_dumper.rs @@ -122,21 +122,16 @@ impl ArrayDumper { data.insert("dist".to_string(), PhpMixed::Array(dist)); } - // corresponds to: foreach (BasePackage::$supportedLinkTypes as $type => $opts) { $links = $package->{'get'.ucfirst($opts['method'])}(); ... } - for (type_name, opts) in SUPPORTED_LINK_TYPES.iter() { - // TODO(phase-b): PackageInterface needs get_links_by_method to mimic PHP magic call - let links: Vec<crate::package::Link> = Vec::new(); - let _ = (&opts.method, &package); + for type_name in SUPPORTED_LINK_TYPES.keys() { + let links = package.get_links_for_type(type_name); if links.is_empty() { continue; } let mut link_map: IndexMap<String, Box<PhpMixed>> = IndexMap::new(); - for link in &links { + for link in links.values() { link_map.insert( link.get_target().to_string(), - Box::new(PhpMixed::String( - link.get_pretty_constraint().unwrap_or_default().to_string(), - )), + Box::new(PhpMixed::String(link.get_pretty_constraint().to_string())), ); } link_map.sort_keys(); |
