aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-07 11:03:13 +0900
committernsfisis <nsfisis@gmail.com>2026-06-07 11:03:13 +0900
commit3a6e69596d4f45ba1c50c6e932004e2160799d0c (patch)
tree1f7175962e5c043b362fe3e82a46beb8fa2fbb40 /crates/shirabe/src
parente1053c6881da1bba409a16783e01a89248507a66 (diff)
downloadphp-shirabe-3a6e69596d4f45ba1c50c6e932004e2160799d0c.tar.gz
php-shirabe-3a6e69596d4f45ba1c50c6e932004e2160799d0c.tar.zst
php-shirabe-3a6e69596d4f45ba1c50c6e932004e2160799d0c.zip
feat(shirabe): resolve phase-b PhpMixed conversion TODOs
Implement self-contained call sites that wrap/unwrap PhpMixed without touching shim bodies: platform-override and authentication IndexMap to PhpMixed conversions, and dev-package-name / version-alias sorts via usort with strcmp/strnatcmp. Drop stale TODO comments where the PhpMixed unwrap was already inlined. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/command/suggests_command.rs9
-rw-r--r--crates/shirabe/src/installed_versions.rs1
-rw-r--r--crates/shirabe/src/repository/filesystem_repository.rs15
-rw-r--r--crates/shirabe/src/repository/vcs/vcs_driver.rs4
-rw-r--r--crates/shirabe/src/util/auth_helper.rs12
5 files changed, 24 insertions, 17 deletions
diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs
index d050ec7..223aa6c 100644
--- a/crates/shirabe/src/command/suggests_command.rs
+++ b/crates/shirabe/src/command/suggests_command.rs
@@ -54,13 +54,14 @@ impl SuggestsCommand {
))];
if composer.get_locker().borrow_mut().is_locked() {
- // TODO(phase-b): get_platform_overrides returns IndexMap<String, String>; PlatformRepository::new expects IndexMap<String, PhpMixed>
- let _platform_overrides = composer
+ let platform_overrides = composer
.get_locker()
.borrow_mut()
.get_platform_overrides()?;
- let platform_overrides: IndexMap<String, PhpMixed> =
- todo!("convert IndexMap<String, String> to IndexMap<String, PhpMixed>");
+ let platform_overrides: IndexMap<String, PhpMixed> = platform_overrides
+ .into_iter()
+ .map(|(k, v)| (k, PhpMixed::String(v)))
+ .collect();
installed_repos.push(RepositoryInterfaceHandle::new(PlatformRepository::new(
vec![],
platform_overrides,
diff --git a/crates/shirabe/src/installed_versions.rs b/crates/shirabe/src/installed_versions.rs
index 90f0c60..77d653f 100644
--- a/crates/shirabe/src/installed_versions.rs
+++ b/crates/shirabe/src/installed_versions.rs
@@ -85,7 +85,6 @@ impl InstalledVersions {
),
);
let flipped = array_flip(&merged);
- // TODO(phase-b): convert flipped (PhpMixed::Array) to IndexMap<String, V>
array_keys(
&flipped
.as_array()
diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs
index d9d3289..4e752d9 100644
--- a/crates/shirabe/src/repository/filesystem_repository.rs
+++ b/crates/shirabe/src/repository/filesystem_repository.rs
@@ -284,8 +284,10 @@ impl FilesystemRepository {
}
// PHP: sort($data['dev-package-names']);
- if let Some(PhpMixed::List(_list)) = data.get_mut("dev-package-names") {
- // TODO(phase-b): sort PhpMixed::List in-place using string comparison; PhpMixed: !Ord.
+ if let Some(PhpMixed::List(list)) = data.get_mut("dev-package-names") {
+ usort(list, |a: &Box<PhpMixed>, b: &Box<PhpMixed>| -> i64 {
+ shirabe_php_shim::strcmp(a.as_string().unwrap_or(""), b.as_string().unwrap_or(""))
+ });
}
// PHP: usort($data['packages'], static function ($a, $b): int { return strcmp($a['name'], $b['name']); });
if let Some(PhpMixed::List(list)) = data.get_mut("packages") {
@@ -611,9 +613,14 @@ impl FilesystemRepository {
if let PhpMixed::Array(version_map) = version.as_mut() {
for key in ["aliases", "replaced", "provided"] {
if let Some(boxed) = version_map.get_mut(key) {
- if let PhpMixed::List(_list) = boxed.as_mut() {
+ if let PhpMixed::List(list) = boxed.as_mut() {
// PHP: sort($versions['versions'][$name][$key], SORT_NATURAL);
- // TODO(phase-b): PhpMixed lacks Ord; needs custom comparator.
+ usort(list, |a: &Box<PhpMixed>, b: &Box<PhpMixed>| -> i64 {
+ shirabe_php_shim::strnatcmp(
+ a.as_string().unwrap_or(""),
+ b.as_string().unwrap_or(""),
+ )
+ });
}
}
}
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs
index d87924a..94c3ff8 100644
--- a/crates/shirabe/src/repository/vcs/vcs_driver.rs
+++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs
@@ -74,7 +74,6 @@ impl VcsDriverBase {
.get("options")
.cloned()
.unwrap_or(PhpMixed::Array(IndexMap::new()));
- // TODO(phase-b): convert PhpMixed::Array options into IndexMap<String, PhpMixed> properly.
let options: IndexMap<String, PhpMixed> = match options_mixed {
PhpMixed::Array(a) => a.into_iter().map(|(k, v)| (k, *v)).collect(),
_ => IndexMap::new(),
@@ -216,7 +215,6 @@ pub trait VcsDriver: VcsDriverInterface {
if self.should_cache(identifier) {
if let Some(res) = self.cache_mut().and_then(|c| c.read(identifier)) {
let parsed = JsonFile::parse_json(Some(&res), None)?;
- // TODO(phase-b): unwrap PhpMixed::Array into IndexMap<String, PhpMixed>.
let parsed_map: Option<IndexMap<String, PhpMixed>> = match parsed {
PhpMixed::Array(a) => Some(a.into_iter().map(|(k, v)| (k, *v)).collect()),
_ => None,
@@ -273,7 +271,6 @@ pub trait VcsDriver: VcsDriverInterface {
Some(&format!("{}:composer.json", identifier)),
)?;
- // TODO(phase-b): unwrap PhpMixed::Array into IndexMap<String, PhpMixed>.
let mut composer: IndexMap<String, PhpMixed> = match composer {
PhpMixed::Array(a) if !a.is_empty() => a.into_iter().map(|(k, v)| (k, *v)).collect(),
_ => return Ok(None),
@@ -315,7 +312,6 @@ pub trait VcsDriver: VcsDriverInterface {
.get("options")
.cloned()
.unwrap_or(PhpMixed::Array(IndexMap::new()));
- // TODO(phase-b): convert PhpMixed::Array options into IndexMap<String, PhpMixed> properly.
let options: IndexMap<String, PhpMixed> = match options_mixed {
PhpMixed::Array(a) => a.into_iter().map(|(k, v)| (k, *v)).collect(),
_ => IndexMap::new(),
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs
index 2709751..7c1691b 100644
--- a/crates/shirabe/src/util/auth_helper.rs
+++ b/crates/shirabe/src/util/auth_helper.rs
@@ -102,8 +102,14 @@ impl AuthHelper {
if store.is_some() {
config_source.add_config_setting(
&format!("http-basic.{}", origin),
- // TODO(phase-b): convert IOInterface auth IndexMap into PhpMixed
- todo!("IOInterface.get_authentication(origin) as PhpMixed"),
+ PhpMixed::Array(
+ self.io
+ .borrow()
+ .get_authentication(origin)
+ .into_iter()
+ .map(|(k, v)| (k, Box::new(v.map_or(PhpMixed::Null, PhpMixed::String))))
+ .collect(),
+ ),
)?;
}
Ok(())
@@ -440,7 +446,6 @@ impl AuthHelper {
password,
);
// PHP: $this->config->get('store-auths') returns 'prompt'|bool
- // TODO(phase-b): decode the PhpMixed result into StoreAuth
store_auth = match self.config.borrow_mut().get("store-auths") {
PhpMixed::Bool(b) => StoreAuth::Bool(b),
PhpMixed::String(ref s) if s == "prompt" => StoreAuth::Prompt,
@@ -467,7 +472,6 @@ impl AuthHelper {
options.insert("http".to_string(), PhpMixed::Array(IndexMap::new()));
}
// PHP: if (!isset($options['http']['header']))
- // TODO(phase-b): mutate nested PhpMixed in place rather than copying
{
let http_has_header = if let Some(PhpMixed::Array(http)) = options.get("http") {
http.contains_key("header")