aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/io
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 16:26:19 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 16:27:24 +0900
commitcb2adb32c90b4150c96518ec5be152be70bcb792 (patch)
tree053c3309975565133ccca156c876dcf4227ffe8e /crates/shirabe/src/io
parent62c827a7b858796a7f51de3eeff1d6c56c3afe7b (diff)
downloadphp-shirabe-cb2adb32c90b4150c96518ec5be152be70bcb792.tar.gz
php-shirabe-cb2adb32c90b4150c96518ec5be152be70bcb792.tar.zst
php-shirabe-cb2adb32c90b4150c96518ec5be152be70bcb792.zip
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<String> - Fix NullIO::load_configuration to use &mut Config and return Result
Diffstat (limited to 'crates/shirabe/src/io')
-rw-r--r--crates/shirabe/src/io/console_io.rs31
-rw-r--r--crates/shirabe/src/io/io_interface.rs28
-rw-r--r--crates/shirabe/src/io/null_io.rs31
3 files changed, 56 insertions, 34 deletions
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<dyn Fn(PhpMixed) -> PhpMixed>,
attempts: Option<i64>,
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<String> {
+ fn ask_and_hide_answer(&mut self, question: String) -> Option<String> {
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<String>,
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<i64>, verbosity: i64);
+ fn overwrite(&mut self, messages: PhpMixed, newline: bool, size: Option<i64>, verbosity: i64);
- fn overwrite_error(&self, messages: PhpMixed, newline: bool, size: Option<i64>, verbosity: i64);
+ fn overwrite_error(
+ &mut self,
+ messages: PhpMixed,
+ newline: bool,
+ size: Option<i64>,
+ 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<dyn Fn(PhpMixed) -> PhpMixed>,
attempts: Option<i64>,
default: PhpMixed,
) -> PhpMixed;
- fn ask_and_hide_answer(&self, question: String) -> Option<String>;
+ fn ask_and_hide_answer(&mut self, question: String) -> Option<String>;
fn select(
- &self,
+ &mut self,
question: String,
choices: Vec<String>,
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<i64>, _verbosity: i64) {}
+ fn overwrite(
+ &mut self,
+ _messages: PhpMixed,
+ _newline: bool,
+ _size: Option<i64>,
+ _verbosity: i64,
+ ) {
+ }
fn overwrite_error(
- &self,
+ &mut self,
_messages: PhpMixed,
_newline: bool,
_size: Option<i64>,
@@ -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<dyn Fn(PhpMixed) -> PhpMixed>,
_attempts: Option<i64>,
@@ -64,12 +71,12 @@ impl IOInterface for NullIO {
default
}
- fn ask_and_hide_answer(&self, _question: String) -> Option<String> {
+ fn ask_and_hide_answer(&mut self, _question: String) -> Option<String> {
None
}
fn select(
- &self,
+ &mut self,
_question: String,
_choices: Vec<String>,
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) {
<Self as BaseIO>::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) {
<Self as BaseIO>::write_error_raw(self, messages, newline, verbosity)
}
@@ -114,7 +121,7 @@ impl IOInterface for NullIO {
<Self as BaseIO>::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<()> {
<Self as BaseIO>::load_configuration(self, config)
}
}