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/init_command.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'crates/shirabe/src/command/init_command.rs') diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index f8bdad9..2a67532 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -757,17 +757,27 @@ impl InitCommand { io.write_error3("\nDefine your dependencies.\n", true, io_interface::NORMAL); // prepare to resolve dependencies - let _repos = self.get_repos(); + let repos = self.get_repos(); let preferred_stability = if let Some(s) = minimum_stability_default.clone().filter(|s| !s.is_empty()) { s } else { "stable".to_string() }; - // TODO(phase-b): repos instanceof CompositeRepository downcast - let _platform_repo: Option<&PlatformRepositoryHandle> = None; - - // (omitted: iterate repos to find PlatformRepository instance) + let platform_repo: Option = if repos.is::() { + let borrowed = repos.borrow(); + let composite = borrowed + .as_any() + .downcast_ref::() + .expect("is::() checked above"); + composite + .get_repositories() + .iter() + .find(|candidate| candidate.is::()) + .and_then(|candidate| candidate.as_platform_repository()) + } else { + None + }; let question = "Would you like to define your dependencies (require) interactively [yes]? ".to_string(); let require: Vec = input @@ -785,7 +795,7 @@ impl InitCommand { input, _output, require, - _platform_repo, + platform_repo.as_ref(), &preferred_stability, false, false, @@ -820,7 +830,7 @@ impl InitCommand { input, _output, require_dev, - _platform_repo, + platform_repo.as_ref(), &preferred_stability, false, false, -- cgit v1.3.1