From c839244d8d09f3036ebfee8eef7eb6b147e593ab Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 19 May 2026 00:10:22 +0900 Subject: fix(compile): fix various compile errors Co-Authored-By: Claude Sonnet 4.6 --- crates/shirabe/src/plugin/command_event.rs | 23 +++++++++------------- .../shirabe/src/plugin/plugin_blocked_exception.rs | 6 ++++++ crates/shirabe/src/plugin/plugin_interface.rs | 6 +++++- crates/shirabe/src/plugin/plugin_manager.rs | 7 ++++--- .../shirabe/src/plugin/post_file_download_event.rs | 4 ++++ crates/shirabe/src/plugin/pre_command_run_event.rs | 17 +++++++--------- crates/shirabe/src/plugin/pre_pool_create_event.rs | 4 ++++ 7 files changed, 39 insertions(+), 28 deletions(-) (limited to 'crates/shirabe/src/plugin') diff --git a/crates/shirabe/src/plugin/command_event.rs b/crates/shirabe/src/plugin/command_event.rs index aa5b366..715f29a 100644 --- a/crates/shirabe/src/plugin/command_event.rs +++ b/crates/shirabe/src/plugin/command_event.rs @@ -1,6 +1,7 @@ //! ref: composer/src/Composer/Plugin/CommandEvent.php use crate::event_dispatcher::event::Event; +use indexmap::IndexMap; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::PhpMixed; @@ -9,34 +10,28 @@ use shirabe_php_shim::PhpMixed; pub struct CommandEvent { inner: Event, command_name: String, - input: Box, - output: Box, } impl CommandEvent { + // TODO(phase-b): input/output dropped because storing &dyn references in an event would + // require lifetime parameters; restore once Plugin API needs them. pub fn new( name: String, command_name: String, - input: Box, - output: Box, - args: Vec, - flags: Vec, + _input: &dyn InputInterface, + _output: &dyn OutputInterface, + args: Vec, + flags: IndexMap, ) -> Self { let inner = Event::new(name, args, flags); Self { inner, command_name, - input, - output, } } - pub fn get_input(&self) -> &dyn InputInterface { - self.input.as_ref() - } - - pub fn get_output(&self) -> &dyn OutputInterface { - self.output.as_ref() + pub fn get_name(&self) -> &str { + self.inner.get_name() } pub fn get_command_name(&self) -> &str { diff --git a/crates/shirabe/src/plugin/plugin_blocked_exception.rs b/crates/shirabe/src/plugin/plugin_blocked_exception.rs index cf3c7ce..fcf52ac 100644 --- a/crates/shirabe/src/plugin/plugin_blocked_exception.rs +++ b/crates/shirabe/src/plugin/plugin_blocked_exception.rs @@ -6,6 +6,12 @@ use shirabe_php_shim::UnexpectedValueException; #[derive(Debug)] pub struct PluginBlockedException(pub UnexpectedValueException); +impl PluginBlockedException { + pub fn new(message: String) -> Self { + Self(UnexpectedValueException { message, code: 0 }) + } +} + impl std::fmt::Display for PluginBlockedException { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) diff --git a/crates/shirabe/src/plugin/plugin_interface.rs b/crates/shirabe/src/plugin/plugin_interface.rs index d536380..a7bb384 100644 --- a/crates/shirabe/src/plugin/plugin_interface.rs +++ b/crates/shirabe/src/plugin/plugin_interface.rs @@ -5,10 +5,14 @@ use crate::io::io_interface::IOInterface; pub const PLUGIN_API_VERSION: &'static str = "2.9.0"; -pub trait PluginInterface { +pub trait PluginInterface: std::fmt::Debug { fn activate(&mut self, composer: &Composer, io: &dyn IOInterface); fn deactivate(&mut self, composer: &Composer, io: &dyn IOInterface); fn uninstall(&mut self, composer: &Composer, io: &dyn IOInterface); + + fn clone_box(&self) -> Box { + todo!() + } } diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs index adf5954..24b8e0b 100644 --- a/crates/shirabe/src/plugin/plugin_manager.rs +++ b/crates/shirabe/src/plugin/plugin_manager.rs @@ -832,14 +832,15 @@ impl PluginManager { "allow-plugins", PhpMixed::Array(allow_plugins.clone()), ); - let mut wrap: IndexMap> = IndexMap::new(); + // TODO(phase-b): get_config() returns &Config, but merge needs &mut Config; ownership needs refactoring let mut inner: IndexMap> = IndexMap::new(); inner.insert( "allow-plugins".to_string(), Box::new(PhpMixed::Array(allow_plugins)), ); - wrap.insert("config".to_string(), Box::new(PhpMixed::Array(inner))); - composer_ref.get_config().merge(PhpMixed::Array(wrap), ""); + let mut wrap: IndexMap = IndexMap::new(); + wrap.insert("config".to_string(), PhpMixed::Array(inner)); + todo!("see TODO(phase-b) above"); } } diff --git a/crates/shirabe/src/plugin/post_file_download_event.rs b/crates/shirabe/src/plugin/post_file_download_event.rs index f0e2569..549807a 100644 --- a/crates/shirabe/src/plugin/post_file_download_event.rs +++ b/crates/shirabe/src/plugin/post_file_download_event.rs @@ -33,6 +33,10 @@ impl PostFileDownloadEvent { } } + pub fn get_name(&self) -> &str { + self.inner.get_name() + } + pub fn get_file_name(&self) -> Option<&str> { self.file_name.as_deref() } diff --git a/crates/shirabe/src/plugin/pre_command_run_event.rs b/crates/shirabe/src/plugin/pre_command_run_event.rs index 40672c0..7a8b2f1 100644 --- a/crates/shirabe/src/plugin/pre_command_run_event.rs +++ b/crates/shirabe/src/plugin/pre_command_run_event.rs @@ -4,24 +4,21 @@ use crate::event_dispatcher::event::Event; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; +#[derive(Debug)] pub struct PreCommandRunEvent { inner: Event, - input: Box, command: String, } impl PreCommandRunEvent { - pub fn new(name: String, input: Box, command: String) -> Self { - let inner = Event::new(name); - Self { - inner, - input, - command, - } + // TODO(phase-b): input dropped because storing a &dyn reference would need lifetime params. + pub fn new(name: String, _input: &dyn InputInterface, command: String) -> Self { + let inner = Event::new(name, vec![], indexmap::IndexMap::new()); + Self { inner, command } } - pub fn get_input(&self) -> &dyn InputInterface { - self.input.as_ref() + pub fn get_name(&self) -> &str { + self.inner.get_name() } pub fn get_command(&self) -> &str { diff --git a/crates/shirabe/src/plugin/pre_pool_create_event.rs b/crates/shirabe/src/plugin/pre_pool_create_event.rs index 5d1a4e9..a1a6bc6 100644 --- a/crates/shirabe/src/plugin/pre_pool_create_event.rs +++ b/crates/shirabe/src/plugin/pre_pool_create_event.rs @@ -21,6 +21,10 @@ pub struct PrePoolCreateEvent { } impl PrePoolCreateEvent { + pub fn get_name(&self) -> &str { + self.inner.get_name() + } + #[allow(clippy::too_many_arguments)] pub fn new( name: String, -- cgit v1.3.1