From 318ea948f5932dfa7942081a269d62fd7161a9bf Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 8 Jun 2026 01:54:56 +0900 Subject: feat(phase-c): resolve reflection/downcast phase-b TODOs Resolve category F phase-b TODOs (class-string, instanceof, get_class, method_exists, __FILE__, Reflection API, downcast). - VcsRepository: dispatch drivers through a VcsDriverKind enum (instantiate/supports/php_class_name) and add constructors to the concrete VCS drivers - repository downcasts via RepositoryInterfaceHandle::downcast_rc and as_any (init/show commands, vcs ValidatingArrayLoader) - BaseCommand::is_self_update_command override replaces an instanceof - Factory::create narrows PartialComposer to ComposerHandle via as_full - InstalledVersions gains set_self_dir/set_installed_is_local_dir, replacing Reflection-based static property mutation - ClassLoader::as_array_iter ports the PHP (array) cast - drop the unnecessary __FILE__ phar branch in self-update application get_class(command) reclassified TODO(plugin); buffer_io StreamableInputInterface downcast and the ValidatingArrayLoader trait redesign left as tracked TODOs. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/show_command.rs | 37 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 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 f324a5c..a316c19 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -33,6 +33,7 @@ use crate::package::version::VersionParser; use crate::package::version::VersionSelector; use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; +use crate::repository::ComposerRepository; use crate::repository::CompositeRepository; use crate::repository::FilterRepository; use crate::repository::InstalledArrayRepository; @@ -745,23 +746,37 @@ impl ShowCommand { } for repo in RepositoryUtils::flatten_repositories(repos.clone(), false) { - // TODO(phase-b): InstalledRepository needs as_repository_interface / get_repositories - // wired through; placeholder classification until then. let r#type = if Self::same_repository(&repo, &platform_repo) { "platform" - } else if let Some(ref lr) = locked_repo { - if Self::same_repository(&repo, lr) { - "locked" - } else { - "available" - } + } else if locked_repo + .as_ref() + .map_or(false, |lr| Self::same_repository(&repo, lr)) + { + "locked" + } else if Self::same_repository(&repo, &installed_repo) + || installed_repo + .borrow() + .as_any() + .downcast_ref::() + .map_or(false, |ir| { + ir.get_repositories().iter().any(|r| r.ptr_eq(&repo)) + }) + { + "installed" } else { "available" }; let type_owned = r#type.to_string(); - // TODO(phase-b): RepositoryInterface needs as_composer_repository_mut downcast helper - if false { - let _ = package_filter.as_deref(); + if let Some(cr_rc) = repo.downcast_rc::() { + let names = cr_rc + .borrow_mut() + .get_package_names(package_filter.as_deref())?; + for name in names { + packages + .entry(type_owned.clone()) + .or_insert_with(IndexMap::new) + .insert(name.clone(), PackageOrName::Name(name)); + } } else { for package in repo.get_packages()? { let existing = packages -- cgit v1.3.1