From 3ef7095aa0c8cdb6c1f15d46304bbe8c2e6393d6 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 22 Aug 2026 19:47:23 +0900 Subject: fix(package): dispatch get_links_for_type on Link::TYPE_* values PHP resolves a link kind through `$package->{'get'.ucfirst($linkType)}()`, so the argument is a `Link::$TYPES` value ("requires", "devRequires", ...). The helper matched the composer.json key names ("require", "require-dev", ...) instead, so every caller passing a `Link::TYPE_*` constant got an empty map back: `show ` printed none of its requires/provides/conflicts/ replaces sections, and `--format=json` carried none of those keys. The two callers that were passing composer.json keys now pass the matching `method`, as PHP does. --- crates/shirabe/src/command/create_project_command.rs | 4 ++-- crates/shirabe/src/command/show_command.rs | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/command') diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index a2b44713..7f85b17d 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -392,8 +392,8 @@ impl CreateProjectCommand { )?)), false, ); - for (r#type, _meta) in SUPPORTED_LINK_TYPES.iter() { - for link in package.get_links_for_type(r#type).values() { + for (r#type, meta) in SUPPORTED_LINK_TYPES.iter() { + for link in package.get_links_for_type(meta.method).values() { if link.get_pretty_constraint() == "self.version" { config_source.add_link( r#type, diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index f1123e14..a4177b1d 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -594,9 +594,6 @@ impl ShowCommand { ) { let title = title.unwrap_or(link_type); let io = self.get_io(); - // TODO(port): `get_links_for_type` matches the composer.json key names ("require", - // "require-dev", ...), not the `Link::TYPE_*` values passed here, so it always returns - // an empty map and these sections never print. PHP dispatches on `Link::$TYPES`. let links = package.get_links_for_type(link_type); if !links.is_empty() { io.write(&format!("\n{}", title)); @@ -844,9 +841,6 @@ impl ShowCommand { package: CompletePackageInterfaceHandle, link_type: &str, ) { - // TODO(port): `get_links_for_type` matches the composer.json key names ("require", - // "require-dev", ...), not the `Link::TYPE_*` values passed here, so it always returns - // an empty map and these keys never reach the JSON. PHP dispatches on `Link::$TYPES`. let links = package.get_links_for_type(link_type); if !links.is_empty() { -- cgit v1.3.1-4-g156e