From e5657c7709fcb4ee0761cc0b5ae1ad1a26d1ad9a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Jun 2026 14:41:41 +0900 Subject: fix(command/show): match PHP null/isset semantics in package output Three porting mismatches caused show/info output to diverge from PHP: - "not found" hint appended " in /composer.json" whenever the working-dir key existed; PHP uses isset(), which is false for the null default. Now only appended when the value is non-null. - printPackages and generatePackageTree inserted "" for a missing description instead of null, so isset() rendered a spurious trailing space (and JSON emitted "" instead of null). Both now preserve null. Un-ignores the eight rendering-gap tests these fix (plus one already passing), and rewrites the remaining ignore reasons to name the real blocker (package categorization, --no-dev filtering, RefCell borrow, installer resolution) instead of a stale generic message. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/show_command.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'crates/shirabe/src/command') diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index fa9c3d9..c52e0bf 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -659,13 +659,10 @@ impl Command for ShowCommand { if input.borrow().get_option("locked")?.as_bool() == Some(true) { hint.push_str(" in lock file"); } - if options.contains_key("working-dir") { + if let Some(working_dir) = options.get("working-dir").filter(|v| !v.is_null()) { hint.push_str(&format!( " in {}/composer.json", - options - .get("working-dir") - .and_then(|v| v.as_string()) - .unwrap_or("") + working_dir.as_string().unwrap_or("") )); } if PlatformRepository::is_platform_package(pf) @@ -1200,7 +1197,10 @@ impl Command for ShowCommand { if write_description && let Some(c) = package.as_complete() { package_view_data.insert( "description".to_string(), - PhpMixed::String(c.get_description().unwrap_or_default()), + match c.get_description() { + Some(d) => PhpMixed::String(d), + None => PhpMixed::Null, + }, ); } if write_path { @@ -2524,12 +2524,13 @@ impl ShowCommand { ); tree.insert( "description".to_string(), - PhpMixed::String( - package - .as_complete() - .map(|c| c.get_description().unwrap_or_default()) - .unwrap_or_default(), - ), + match package.as_complete() { + Some(c) => match c.get_description() { + Some(d) => PhpMixed::String(d), + None => PhpMixed::Null, + }, + None => PhpMixed::String(String::new()), + }, ); if !children.is_empty() { -- cgit v1.3.1