diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-02 16:16:51 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-02 16:16:51 +0900 |
| commit | 6047bcc3e63ab84dfc67bce94f402f1bfa3f58d5 (patch) | |
| tree | e0fc935abf0cebb2c557581fbfd098bdef35d558 /crates/shirabe/src/command/repository_command.rs | |
| parent | 4361059d3bb27916179acfebb8889f1863319bb9 (diff) | |
| download | php-shirabe-6047bcc3e63ab84dfc67bce94f402f1bfa3f58d5.tar.gz php-shirabe-6047bcc3e63ab84dfc67bce94f402f1bfa3f58d5.tar.zst php-shirabe-6047bcc3e63ab84dfc67bce94f402f1bfa3f58d5.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/repository_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/repository_command.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs index d0add253..31d2de3f 100644 --- a/crates/shirabe/src/command/repository_command.rs +++ b/crates/shirabe/src/command/repository_command.rs @@ -15,8 +15,8 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ - InvalidArgumentException, PHP_URL_HOST, PhpMixed, RuntimeException, parse_url, php_regex, - strtolower, + InvalidArgumentException, PHP_URL_HOST, PhpMixed, RuntimeException, impl_php_class, parse_url, + php_regex, strtolower, }; #[derive(Debug)] @@ -28,6 +28,8 @@ pub struct RepositoryCommand { config_source: std::cell::RefCell<Option<JsonConfigSource>>, } +impl_php_class!(RepositoryCommand, r"Composer\Command\RepositoryCommand"); + impl Default for RepositoryCommand { fn default() -> Self { Self::new() @@ -588,10 +590,7 @@ impl Command for RepositoryCommand { crate::command::base_command::base_command_complete(self, input, suggestions) } - shirabe_external_packages::delegate_command_trait_impls_to_inner!( - base_command_data, - "Composer\\Command\\RepositoryCommand" - ); + shirabe_external_packages::delegate_command_trait_impls_to_inner!(base_command_data); } impl BaseCommand for RepositoryCommand { |
