aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/question
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-19 00:10:22 +0900
committernsfisis <nsfisis@gmail.com>2026-05-19 00:11:03 +0900
commitc839244d8d09f3036ebfee8eef7eb6b147e593ab (patch)
treefe48c94f2c2e62468beef5ff1a8f3cff6adeef4f /crates/shirabe/src/question
parent48839250146b217e2756ed3c0e624fd341b54d6c (diff)
downloadphp-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.gz
php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.zst
php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.zip
fix(compile): fix various compile errors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/question')
-rw-r--r--crates/shirabe/src/question/strict_confirmation_question.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/crates/shirabe/src/question/strict_confirmation_question.rs b/crates/shirabe/src/question/strict_confirmation_question.rs
index eea6629..b3a7196 100644
--- a/crates/shirabe/src/question/strict_confirmation_question.rs
+++ b/crates/shirabe/src/question/strict_confirmation_question.rs
@@ -19,7 +19,7 @@ impl StrictConfirmationQuestion {
true_answer_regex: String,
false_answer_regex: String,
) -> Self {
- let inner = Question::new(question, PhpMixed::Bool(default));
+ let inner = Question::new(&question, Some(PhpMixed::Bool(default)));
let mut this = Self {
inner,
true_answer_regex,
@@ -28,7 +28,7 @@ impl StrictConfirmationQuestion {
let normalizer = this.get_default_normalizer();
let validator = this.get_default_validator();
this.inner.set_normalizer(normalizer);
- this.inner.set_validator(validator);
+ this.inner.set_validator(Some(validator));
this
}
@@ -41,14 +41,14 @@ impl StrictConfirmationQuestion {
if is_bool(answer) {
return answer.clone();
}
- if empty(answer) && !empty(&default) {
- return default.clone();
+ if empty(answer) && default.as_ref().is_some_and(|d| !empty(d)) {
+ return default.clone().unwrap_or(PhpMixed::Null);
}
if let PhpMixed::String(s) = answer {
- if Preg::is_match(&true_regex, s) {
+ if Preg::is_match(&true_regex, s).unwrap_or(false) {
return PhpMixed::Bool(true);
}
- if Preg::is_match(&false_regex, s) {
+ if Preg::is_match(&false_regex, s).unwrap_or(false) {
return PhpMixed::Bool(false);
}
}
@@ -56,16 +56,17 @@ impl StrictConfirmationQuestion {
})
}
- fn get_default_validator(&self) -> Box<dyn Fn(&PhpMixed) -> Result<PhpMixed>> {
- Box::new(|answer: &PhpMixed| {
- if !is_bool(answer) {
+ fn get_default_validator(&self) -> Box<dyn Fn(Option<PhpMixed>) -> Result<PhpMixed>> {
+ Box::new(|answer: Option<PhpMixed>| {
+ let answer = answer.unwrap_or(PhpMixed::Null);
+ if !is_bool(&answer) {
return Err(InvalidArgumentException {
message: "Please answer yes, y, no, or n.".to_string(),
code: 0,
}
.into());
}
- Ok(answer.clone())
+ Ok(answer)
})
}
}