From 632c9793927a30c4bca3c91888e66b369d732dfe Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 8 Jun 2026 04:22:49 +0900 Subject: feat(phase-c): resolve PhpMixed-conversion phase-b TODOs Implement the foundational PhpMixed conversion infrastructure (From, order-sensitive PartialEq matching PHP ===) and resolve the category-G phase-b TODOs that depend on it: - Fix VCS driver cache paths that discarded parsed JSON or diverged on null caches (svn/forgejo/gitlab/git-bitbucket/github). - Wire up real conversions previously stubbed or dropped: suggests platform config, audit ignore-severities, composer_repository search and ProviderInfo, class_loader prefix/classmap merges, locker lock diff comparison, advisory JSON serialization, SPDX license fields. - Make GenericRule take a typed ReasonData; populate RULE_ROOT_REQUIRE with the constraint and convert PhpMixed at the call sites. --- crates/shirabe/src/command/show_command.rs | 39 ++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/command/show_command.rs') diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 7a2c452..e99005e 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -1870,12 +1870,20 @@ impl ShowCommand { let out = match license { None => license_id.clone(), Some(license) => { - // TODO(phase-b): SpdxLicenses returns PhpMixed; field access (osi/fullname/url) - // is placeholder until PHP array offsets are wired. - let _ = &license; - let fullname = String::new(); - let url = String::new(); - let is_osi = false; + // SpdxLicenses::getLicenseByIdentifier returns [0 => fullname, 1 => osiApproved, 2 => url]. + let list = license.as_list(); + let fullname = list + .and_then(|l| l.get(0)) + .and_then(|v| v.as_string()) + .unwrap_or("") + .to_string(); + let is_osi = + list.and_then(|l| l.get(1)).and_then(|v| v.as_bool()) == Some(true); + let url = list + .and_then(|l| l.get(2)) + .and_then(|v| v.as_string()) + .unwrap_or("") + .to_string(); if is_osi { format!("{} ({}) (OSI approved) {}", fullname, license_id, url) } else { @@ -2116,12 +2124,23 @@ impl ShowCommand { match license { None => PhpMixed::String(license_id), Some(l) => { - // TODO(phase-b): SpdxLicenses returns PhpMixed; field access placeholder. - let _ = &l; + // PHP shape: ['name' => $license[0], 'osi' => $licenseId, 'url' => $license[2]]. + // Note 'osi' is the license id string, not the OSI-approved flag. + let list = l.as_list(); + let name = list + .and_then(|x| x.get(0)) + .and_then(|v| v.as_string()) + .unwrap_or("") + .to_string(); + let url = list + .and_then(|x| x.get(2)) + .and_then(|v| v.as_string()) + .unwrap_or("") + .to_string(); let mut m: IndexMap = IndexMap::new(); - m.insert("name".to_string(), PhpMixed::String(String::new())); + m.insert("name".to_string(), PhpMixed::String(name)); m.insert("osi".to_string(), PhpMixed::String(license_id)); - m.insert("url".to_string(), PhpMixed::String(String::new())); + m.insert("url".to_string(), PhpMixed::String(url)); PhpMixed::Array(m.into_iter().map(|(k, v)| (k, Box::new(v))).collect()) } } -- cgit v1.3.1