diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-08 04:22:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-08 04:23:11 +0900 |
| commit | 632c9793927a30c4bca3c91888e66b369d732dfe (patch) | |
| tree | 5bafb9d7fa2523d5a2f8d70ff59c3173e962e389 /crates/shirabe/src/command/show_command.rs | |
| parent | 243450fee9853c2fea66ae0642dabb8db5227d6f (diff) | |
| download | php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.gz php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.zst php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.zip | |
feat(phase-c): resolve PhpMixed-conversion phase-b TODOs
Implement the foundational PhpMixed conversion infrastructure
(From<bool|i64|f64|String>, 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.
Diffstat (limited to 'crates/shirabe/src/command/show_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/show_command.rs | 39 |
1 files changed, 29 insertions, 10 deletions
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<String, PhpMixed> = 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()) } } |
