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/self_update_command.rs | 44 ++++------------------- 1 file changed, 6 insertions(+), 38 deletions(-) (limited to 'crates/shirabe/src/command/self_update_command.rs') diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index 127661a..d0ffcde 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -15,8 +15,8 @@ use shirabe_php_shim::{ function_exists, hash_file, in_array, ini_get, is_array, is_file, is_numeric, is_writable, iterator_to_array, json_decode, openssl_free_key, openssl_get_md_methods, openssl_pkey_get_public, openssl_verify, posix_geteuid, posix_getpwuid, random_int, rename, - server_argv, sprintf, str_contains, str_replace, strpos, strtolower, strtr, tempnam, unlink, - usleep, version_compare, + server_argv, sprintf, str_replace, strpos, strtolower, strtr, tempnam, unlink, usleep, + version_compare, }; use crate::command::{BaseCommand, BaseCommandData, HasBaseCommandData}; @@ -78,42 +78,6 @@ impl SelfUpdateCommand { input: std::rc::Rc>, output: std::rc::Rc>, ) -> Result { - // TODO(phase-b): __FILE__ / __DIR__ have no direct Rust equivalent - let file_path: &str = ""; - let dir_path: &str = ""; - - if strpos(file_path, "phar:") != Some(0) { - if str_contains(&strtr(dir_path, "\\", "/"), "vendor/composer/composer") { - let proj_dir = shirabe_php_shim::dirname_levels(dir_path, 6); - output.borrow().writeln( - "This instance of Composer does not have the self-update command.", - io_interface::NORMAL, - ); - output.borrow().writeln( - &format!( - "You are running Composer installed as a package in your current project (\"{}\").", - proj_dir - ), - io_interface::NORMAL, - ); - output.borrow().writeln( - "To update Composer, download a composer.phar from https://getcomposer.org and then run `composer.phar update composer/composer` in your project.", - io_interface::NORMAL, - ); - } else { - output.borrow().writeln( - "This instance of Composer does not have the self-update command.", - io_interface::NORMAL, - ); - output.borrow().writeln( - "This could be due to a number of reasons, such as Composer being installed as a system package on your OS, or Composer being installed as a package in the current project.", - io_interface::NORMAL, - ); - } - - return Ok(1); - } - if server_argv().get(0).map(|s| s.as_str()) == Some("Standard input code") { return Ok(1); } @@ -1207,4 +1171,8 @@ impl HasBaseCommandData for SelfUpdateCommand { fn base_command_data_mut(&mut self) -> &mut BaseCommandData { &mut self.base_command_data } + + fn is_self_update_command(&self) -> bool { + true + } } -- cgit v1.3.1