diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-08 01:54:56 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-08 01:54:56 +0900 |
| commit | 318ea948f5932dfa7942081a269d62fd7161a9bf (patch) | |
| tree | 0fff2fe818f87a20dea89a51901f9e16071f2f53 /crates/shirabe/src/command/self_update_command.rs | |
| parent | f232d7f9d2936ef84bd904cacd21c12cb7012b34 (diff) | |
| download | php-shirabe-318ea948f5932dfa7942081a269d62fd7161a9bf.tar.gz php-shirabe-318ea948f5932dfa7942081a269d62fd7161a9bf.tar.zst php-shirabe-318ea948f5932dfa7942081a269d62fd7161a9bf.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/self_update_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/self_update_command.rs | 44 |
1 files changed, 6 insertions, 38 deletions
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<std::cell::RefCell<dyn InputInterface>>, output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> Result<i64> { - // 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( - "<error>This instance of Composer does not have the self-update command.</error>", - io_interface::NORMAL, - ); - output.borrow().writeln( - &format!( - "<comment>You are running Composer installed as a package in your current project (\"{}\").</comment>", - proj_dir - ), - io_interface::NORMAL, - ); - output.borrow().writeln( - "<comment>To update Composer, download a composer.phar from https://getcomposer.org and then run `composer.phar update composer/composer` in your project.</comment>", - io_interface::NORMAL, - ); - } else { - output.borrow().writeln( - "<error>This instance of Composer does not have the self-update command.</error>", - io_interface::NORMAL, - ); - output.borrow().writeln( - "<comment>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.</comment>", - 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 + } } |
