diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-17 21:24:24 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-17 21:24:34 +0900 |
| commit | e752ff0a7e21334c0b9b9e1b87d4965ea8760fd5 (patch) | |
| tree | 55345a77a769293930f3e77c02ba61eb0af4ffc4 /crates/shirabe/src/console | |
| parent | 07c1ef1aea3a0c60484fdada89de7c5a3b7cf7c6 (diff) | |
| download | php-shirabe-e752ff0a7e21334c0b9b9e1b87d4965ea8760fd5.tar.gz php-shirabe-e752ff0a7e21334c0b9b9e1b87d4965ea8760fd5.tar.zst php-shirabe-e752ff0a7e21334c0b9b9e1b87d4965ea8760fd5.zip | |
fix(compile): convert Command struct to trait
Symfony Command was a struct but used as dyn Trait (Box<dyn Command>)
in console/application.rs. Convert it to a trait with CommandBase as
the concrete stub, and add impl Command for all Composer commands.
Diffstat (limited to 'crates/shirabe/src/console')
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index dec25ce..07996bb 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -6,7 +6,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::xdebug_handler::xdebug_handler::XdebugHandler; use shirabe_external_packages::seld::json_lint::parsing_exception::ParsingException; use shirabe_external_packages::symfony::component::console::application::Application as BaseApplication; -use shirabe_external_packages::symfony::component::console::command::command::Command as SymfonyCommand; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::exception::command_not_found_exception::CommandNotFoundException; use shirabe_external_packages::symfony::component::console::exception::exception_interface::ExceptionInterface; use shirabe_external_packages::symfony::component::console::helper::helper_set::HelperSet; @@ -617,7 +617,7 @@ impl Application { // if the command is not an array of commands, and points to a valid Command subclass, import its details directly let dummy_str = dummy.as_string().unwrap_or(""); - let cmd: Box<dyn SymfonyCommand> = if is_string(dummy) + let cmd: Box<dyn Command> = if is_string(dummy) && shirabe_php_shim::class_exists(dummy_str) && is_subclass_of( dummy_str, @@ -630,7 +630,7 @@ impl Application { io.write_error(&format!("<warning>The script named {} extends SingleCommandApplication which is not compatible with Composer 2.9+, make sure you extend Symfony\\Component\\Console\\Command instead.</warning>", script)); } let mut cmd = shirabe_php_shim::instantiate_class::< - Box<dyn SymfonyCommand>, + Box<dyn Command>, >( dummy_str, vec![PhpMixed::String(script.clone())], @@ -984,9 +984,9 @@ impl Application { } /// Initializes all the composer commands. - pub(crate) fn get_default_commands(&self) -> Vec<Box<dyn SymfonyCommand>> { + pub(crate) fn get_default_commands(&self) -> Vec<Box<dyn Command>> { let mut cmds = self.inner.get_default_commands(); - let extras: Vec<Box<dyn SymfonyCommand>> = vec![ + let extras: Vec<Box<dyn Command>> = vec![ Box::new(AboutCommand::new()), Box::new(ConfigCommand::new()), Box::new(DependsCommand::new()), @@ -1101,9 +1101,9 @@ impl Application { definition } - fn get_plugin_commands(&mut self) -> anyhow::Result<Vec<Box<dyn SymfonyCommand>>> { + fn get_plugin_commands(&mut self) -> anyhow::Result<Vec<Box<dyn Command>>> { // TODO(plugin): plugin command discovery is part of the plugin API - let mut commands: Vec<Box<dyn SymfonyCommand>> = vec![]; + let mut commands: Vec<Box<dyn Command>> = vec![]; let composer = self.get_composer(false, Some(false), None)?.cloned(); let composer = match composer { |
