From cb2adb32c90b4150c96518ec5be152be70bcb792 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 16:26:19 +0900 Subject: fix(compile): fix IOInterface method signature mismatches - Change write/write_error/write_raw/write_error_raw/overwrite/ overwrite_error/ask/ask_confirmation/ask_and_validate/ ask_and_hide_answer/select to &mut self in trait and NullIO - Change ask-family question params from PhpMixed to String in ConsoleIO, converting to PhpMixed::String internally - Change ConsoleIO::select choices param from PhpMixed to Vec - Fix NullIO::load_configuration to use &mut Config and return Result --- .../src/downloader/change_report_interface.rs | 6 ++++- crates/shirabe/src/io/console_io.rs | 31 ++++++++++++++-------- crates/shirabe/src/io/io_interface.rs | 28 +++++++++++-------- crates/shirabe/src/io/null_io.rs | 31 +++++++++++++--------- 4 files changed, 61 insertions(+), 35 deletions(-) (limited to 'crates') diff --git a/crates/shirabe/src/downloader/change_report_interface.rs b/crates/shirabe/src/downloader/change_report_interface.rs index 1b1c813..2148689 100644 --- a/crates/shirabe/src/downloader/change_report_interface.rs +++ b/crates/shirabe/src/downloader/change_report_interface.rs @@ -5,5 +5,9 @@ use anyhow::Result; use crate::package::package_interface::PackageInterface; pub trait ChangeReportInterface { - fn get_local_changes(&self, package: &dyn PackageInterface, path: &str) -> Result>; + fn get_local_changes( + &self, + package: &dyn PackageInterface, + path: &str, + ) -> Result>; } diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index ff1ed0f..91a15d3 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -454,11 +454,11 @@ impl IOInterface for ConsoleIO { self.do_overwrite(messages, newline, size, true, verbosity); } - fn ask(&mut self, question: PhpMixed, default: PhpMixed) -> PhpMixed { + fn ask(&mut self, question: String, default: PhpMixed) -> PhpMixed { // PHP: $helper = $this->helperSet->get('question'); let helper = self.helper_set.get("question"); let question = Question::new( - Self::sanitize(question, true), + Self::sanitize(PhpMixed::String(question), true), if is_string(&default) { Self::sanitize(default, true) } else { @@ -469,11 +469,11 @@ impl IOInterface for ConsoleIO { helper.ask(&*self.input, self.get_error_output(), &question) } - fn ask_confirmation(&mut self, question: PhpMixed, default: bool) -> bool { + fn ask_confirmation(&mut self, question: String, default: bool) -> bool { let helper = self.helper_set.get("question"); let default_mixed = PhpMixed::Bool(default); let question = StrictConfirmationQuestion::new( - Self::sanitize(question, true), + Self::sanitize(PhpMixed::String(question), true), if is_string(&default_mixed) { Self::sanitize(default_mixed, true) } else { @@ -489,14 +489,14 @@ impl IOInterface for ConsoleIO { fn ask_and_validate( &mut self, - question: PhpMixed, + question: String, validator: Box PhpMixed>, attempts: Option, default: PhpMixed, ) -> PhpMixed { let helper = self.helper_set.get("question"); let mut question = Question::new( - Self::sanitize(question, true), + Self::sanitize(PhpMixed::String(question), true), if is_string(&default) { Self::sanitize(default, true) } else { @@ -509,9 +509,12 @@ impl IOInterface for ConsoleIO { helper.ask(&*self.input, self.get_error_output(), &question) } - fn ask_and_hide_answer(&mut self, question: PhpMixed) -> Option { + fn ask_and_hide_answer(&mut self, question: String) -> Option { let helper = self.helper_set.get("question"); - let mut question = Question::new(Self::sanitize(question, true), PhpMixed::Null); + let mut question = Question::new( + Self::sanitize(PhpMixed::String(question), true), + PhpMixed::Null, + ); question.set_hidden(true); helper @@ -522,17 +525,23 @@ impl IOInterface for ConsoleIO { fn select( &mut self, - question: PhpMixed, - choices: PhpMixed, + question: String, + choices: Vec, default: PhpMixed, // PHP: int|false attempts attempts: PhpMixed, error_message: String, multiselect: bool, ) -> PhpMixed { + let choices: PhpMixed = PhpMixed::List( + choices + .into_iter() + .map(|s| Box::new(PhpMixed::String(s))) + .collect(), + ); let helper = self.helper_set.get("question"); let mut question = ChoiceQuestion::new( - Self::sanitize(question, true), + Self::sanitize(PhpMixed::String(question), true), Self::sanitize(choices.clone(), true), if is_string(&default) { Self::sanitize(default, true) diff --git a/crates/shirabe/src/io/io_interface.rs b/crates/shirabe/src/io/io_interface.rs index 406a3ff..3826bb3 100644 --- a/crates/shirabe/src/io/io_interface.rs +++ b/crates/shirabe/src/io/io_interface.rs @@ -22,34 +22,40 @@ pub trait IOInterface: LoggerInterface { fn is_decorated(&self) -> bool; - fn write(&self, messages: PhpMixed, newline: bool, verbosity: i64); + fn write(&mut self, messages: PhpMixed, newline: bool, verbosity: i64); - fn write_error(&self, messages: PhpMixed, newline: bool, verbosity: i64); + fn write_error(&mut self, messages: PhpMixed, newline: bool, verbosity: i64); - fn write_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64); + fn write_raw(&mut self, messages: PhpMixed, newline: bool, verbosity: i64); - fn write_error_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64); + fn write_error_raw(&mut self, messages: PhpMixed, newline: bool, verbosity: i64); - fn overwrite(&self, messages: PhpMixed, newline: bool, size: Option, verbosity: i64); + fn overwrite(&mut self, messages: PhpMixed, newline: bool, size: Option, verbosity: i64); - fn overwrite_error(&self, messages: PhpMixed, newline: bool, size: Option, verbosity: i64); + fn overwrite_error( + &mut self, + messages: PhpMixed, + newline: bool, + size: Option, + verbosity: i64, + ); - fn ask(&self, question: String, default: PhpMixed) -> PhpMixed; + fn ask(&mut self, question: String, default: PhpMixed) -> PhpMixed; - fn ask_confirmation(&self, question: String, default: bool) -> bool; + fn ask_confirmation(&mut self, question: String, default: bool) -> bool; fn ask_and_validate( - &self, + &mut self, question: String, validator: Box PhpMixed>, attempts: Option, default: PhpMixed, ) -> PhpMixed; - fn ask_and_hide_answer(&self, question: String) -> Option; + fn ask_and_hide_answer(&mut self, question: String) -> Option; fn select( - &self, + &mut self, question: String, choices: Vec, default: PhpMixed, diff --git a/crates/shirabe/src/io/null_io.rs b/crates/shirabe/src/io/null_io.rs index 0399bcb..f229839 100644 --- a/crates/shirabe/src/io/null_io.rs +++ b/crates/shirabe/src/io/null_io.rs @@ -31,14 +31,21 @@ impl IOInterface for NullIO { false } - fn write(&self, _messages: PhpMixed, _newline: bool, _verbosity: i64) {} + fn write(&mut self, _messages: PhpMixed, _newline: bool, _verbosity: i64) {} - fn write_error(&self, _messages: PhpMixed, _newline: bool, _verbosity: i64) {} + fn write_error(&mut self, _messages: PhpMixed, _newline: bool, _verbosity: i64) {} - fn overwrite(&self, _messages: PhpMixed, _newline: bool, _size: Option, _verbosity: i64) {} + fn overwrite( + &mut self, + _messages: PhpMixed, + _newline: bool, + _size: Option, + _verbosity: i64, + ) { + } fn overwrite_error( - &self, + &mut self, _messages: PhpMixed, _newline: bool, _size: Option, @@ -46,16 +53,16 @@ impl IOInterface for NullIO { ) { } - fn ask(&self, _question: String, default: PhpMixed) -> PhpMixed { + fn ask(&mut self, _question: String, default: PhpMixed) -> PhpMixed { default } - fn ask_confirmation(&self, _question: String, default: bool) -> bool { + fn ask_confirmation(&mut self, _question: String, default: bool) -> bool { default } fn ask_and_validate( - &self, + &mut self, _question: String, _validator: Box PhpMixed>, _attempts: Option, @@ -64,12 +71,12 @@ impl IOInterface for NullIO { default } - fn ask_and_hide_answer(&self, _question: String) -> Option { + fn ask_and_hide_answer(&mut self, _question: String) -> Option { None } fn select( - &self, + &mut self, _question: String, _choices: Vec, default: PhpMixed, @@ -80,11 +87,11 @@ impl IOInterface for NullIO { default } - fn write_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64) { + fn write_raw(&mut self, messages: PhpMixed, newline: bool, verbosity: i64) { ::write_raw(self, messages, newline, verbosity) } - fn write_error_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64) { + fn write_error_raw(&mut self, messages: PhpMixed, newline: bool, verbosity: i64) { ::write_error_raw(self, messages, newline, verbosity) } @@ -114,7 +121,7 @@ impl IOInterface for NullIO { ::set_authentication(self, repository_name, username, password) } - fn load_configuration(&mut self, config: &crate::config::Config) { + fn load_configuration(&mut self, config: &mut crate::config::Config) -> anyhow::Result<()> { ::load_configuration(self, config) } } -- cgit v1.3.1