From 6047bcc3e63ab84dfc67bce94f402f1bfa3f58d5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Aug 2026 16:16:51 +0900 Subject: refactor(php-shim): introduce PhpClass for reporting PHP class names Rust has no runtime class name, so `Command::get_class` existed purely to let each command hand back its PHP class name, supplied through the two-argument variant of `delegate_command_trait_impls_to_inner!` at the impl site. Replace it with a general `PhpClass` trait plus an `impl_php_class!` macro, so the name is stated once next to the type definition and the mechanism is reusable outside commands. `Command` gains `PhpClass` as a supertrait and drops `get_class`, and `VcsDriverKind`'s hand-rolled `php_class_name` table moves onto the trait. Behavior is unchanged: the same class-name strings are reported, and the base command state still panics when asked for a name it cannot supply. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/command/update_command.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/command/update_command.rs') diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index b7cced87..8dcf7061 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -34,7 +34,8 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_intersect, - array_keys, array_merge_map, array_search_in_vec, in_array, php_regex, strtolower, + array_keys, array_merge_map, array_search_in_vec, impl_php_class, in_array, php_regex, + strtolower, }; use shirabe_semver::Intervals; use shirabe_semver::constraint::MultiConstraint; @@ -44,6 +45,8 @@ pub struct UpdateCommand { base_command_data: BaseCommandData, } +impl_php_class!(UpdateCommand, r"Composer\Command\UpdateCommand"); + impl Default for UpdateCommand { fn default() -> Self { Self::new() @@ -587,10 +590,7 @@ impl Command for UpdateCommand { crate::command::base_command::base_command_complete(self, input, suggestions) } - shirabe_external_packages::delegate_command_trait_impls_to_inner!( - base_command_data, - "Composer\\Command\\UpdateCommand" - ); + shirabe_external_packages::delegate_command_trait_impls_to_inner!(base_command_data); } impl BaseCommand for UpdateCommand { -- cgit v1.3.1