aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/command.rs11
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs3
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs1
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs11
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs10
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs29
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs15
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs2
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs39
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/table.rs10
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs20
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/array_input.rs23
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/input.rs8
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs32
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs3
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/question.rs26
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs8
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/process.rs71
-rw-r--r--crates/shirabe-external-packages/src/symfony/string/code_point_string.rs2
25 files changed, 152 insertions, 204 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/command.rs b/crates/shirabe-external-packages/src/symfony/console/command/command.rs
index 89f4ae2..527f0c5 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/command.rs
@@ -406,7 +406,7 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
self.merge_application_definition(true);
// bind the input against the command specific arguments/options
- match input.borrow_mut().bind(&*self.get_definition()) {
+ match input.borrow_mut().bind(&self.get_definition()) {
Ok(()) => {}
Err(e) => {
if !self.get_ignore_validation_errors() {
@@ -458,17 +458,16 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
input.borrow_mut().validate()?;
- let status_code: PhpMixed;
- if self.get_code().is_some() {
+ let status_code: PhpMixed = if self.get_code().is_some() {
let code = self.get_code();
let code = code.as_ref().unwrap();
- status_code = code(&mut *input.borrow_mut(), &mut *output.borrow_mut());
+ code(&mut *input.borrow_mut(), &mut *output.borrow_mut())
} else {
let executed = self.execute(input.clone(), output.clone())?;
- status_code = PhpMixed::from(executed);
// PHP also raises \TypeError when execute() does not return int; in this
// strongly-typed port execute() already returns an int, so the check is moot.
- }
+ PhpMixed::from(executed)
+ };
// is_numeric($statusCode) ? (int) $statusCode : 0
Ok(shirabe_php_shim::is_numeric_to_int(&status_code))
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
index da59a75..3ed968e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/vendor/symfony/console/Command/CompleteCommand.php
use indexmap::IndexMap;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
@@ -327,7 +326,7 @@ impl Command for CompleteCommand {
}
Some(command) => {
command.borrow().merge_application_definition(false);
- completion_input.bind(&*command.borrow().get_definition())?;
+ completion_input.bind(&command.borrow().get_definition())?;
if CompletionInput::TYPE_OPTION_NAME == completion_input.get_completion_type() {
self.log(&format!(
diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs b/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs
index bd51b8e..fe979cd 100644
--- a/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs
@@ -1,6 +1,5 @@
//! ref: composer/vendor/symfony/console/Completion/CompletionInput.php
-use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
use crate::symfony::console::input::argv_input::ArgvInput;
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
index 4961bd8..8e54d9e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
@@ -62,7 +62,7 @@ impl TextDescriptor {
self.write_text(
&format!(
" <info>{}</info> {}{}{}",
- argument.get_name().to_string(),
+ argument.get_name(),
shirabe_php_shim::str_repeat(" ", spacing_width as usize),
// + 4 = 2 spaces before <info>, 2 spaces after </info>
Preg::replace(
@@ -114,14 +114,14 @@ impl TextDescriptor {
let synopsis = format!(
"{}{}",
if option.get_shortcut().is_some() {
- format!("-{}, ", option.get_shortcut().unwrap().to_string())
+ format!("-{}, ", option.get_shortcut().unwrap())
} else {
" ".to_string()
},
if option.is_negatable() {
format!("--{0}|--no-{0}", option.get_name().to_string())
} else {
- format!("--{0}{1}", option.get_name().to_string(), value.clone())
+ format!("--{0}{1}", option.get_name(), value.clone())
}
);
@@ -400,10 +400,11 @@ impl TextDescriptor {
};
self.write_text(
&format!(
- " <info>{}</info>{}{}",
+ " <info>{}</info>{}{}{}",
name.clone(),
shirabe_php_shim::str_repeat(" ", spacing_width as usize),
- format!("{}{}", command_aliases, command.get_description()),
+ command_aliases,
+ command.get_description(),
),
&options,
);
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs
index 77fca93..c2770a4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs
@@ -336,14 +336,8 @@ impl XmlDescriptor {
/// getInputOptionDocument when the default is an array (returns it verbatim).
fn default_values_as_strings(&self, default: &PhpMixed) -> Vec<String> {
match default {
- PhpMixed::List(list) => list
- .iter()
- .map(|v| shirabe_php_shim::php_to_string(v))
- .collect(),
- PhpMixed::Array(arr) => arr
- .values()
- .map(|v| shirabe_php_shim::php_to_string(v))
- .collect(),
+ PhpMixed::List(list) => list.iter().map(shirabe_php_shim::php_to_string).collect(),
+ PhpMixed::Array(arr) => arr.values().map(shirabe_php_shim::php_to_string).collect(),
_ => vec![],
}
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs
index d528b4a..030fda4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs
@@ -56,8 +56,8 @@ impl DebugFormatterHelper {
format!(
"{}<bg=blue;fg=white> {} </> <fg=blue>{}</>\n",
self.get_border(id),
- prefix.to_string(),
- message.to_string(),
+ prefix,
+ message,
)
}
@@ -81,7 +81,7 @@ impl DebugFormatterHelper {
message.push_str(&format!(
"{}<bg=red;fg=white> {} </> ",
self.get_border(id),
- error_prefix.to_string(),
+ error_prefix,
));
self.started.get_mut(id).unwrap().err = true;
}
@@ -91,7 +91,7 @@ impl DebugFormatterHelper {
&format!(
"\n{}<bg=red;fg=white> {} </> ",
self.get_border(id),
- error_prefix.to_string(),
+ error_prefix,
),
buffer,
));
@@ -104,7 +104,7 @@ impl DebugFormatterHelper {
message.push_str(&format!(
"{}<bg=green;fg=white> {} </> ",
self.get_border(id),
- prefix.to_string(),
+ prefix,
));
self.started.get_mut(id).unwrap().out = true;
}
@@ -114,7 +114,7 @@ impl DebugFormatterHelper {
&format!(
"\n{}<bg=green;fg=white> {} </> ",
self.get_border(id),
- prefix.to_string(),
+ prefix,
),
buffer,
));
@@ -134,19 +134,19 @@ impl DebugFormatterHelper {
if successful {
return format!(
"{}{}<bg=green;fg=white> {} </> <fg=green>{}</>\n",
- trailing_eol.to_string(),
+ trailing_eol,
self.get_border(id),
- prefix.to_string(),
- message.to_string(),
+ prefix,
+ message,
);
}
let message = format!(
"{}{}<bg=red;fg=white> {} </> <fg=red>{}</>\n",
- trailing_eol.to_string(),
+ trailing_eol,
self.get_border(id),
- prefix.to_string(),
- message.to_string(),
+ prefix,
+ message,
);
if let Some(session) = self.started.get_mut(id) {
@@ -158,10 +158,7 @@ impl DebugFormatterHelper {
}
fn get_border(&self, id: &str) -> String {
- format!(
- "<bg={}> </>",
- COLORS[self.started[id].border as usize].to_string(),
- )
+ format!("<bg={}> </>", COLORS[self.started[id].border as usize],)
}
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs
index 8a6c97f..e1dbd1e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs
@@ -16,13 +16,7 @@ pub struct FormatterHelper {
impl FormatterHelper {
/// Formats a message within a section.
pub fn format_section(&self, section: &str, message: &str, style: &str) -> String {
- format!(
- "<{}>[{}]</{}> {}",
- style.to_string(),
- section.to_string(),
- style.to_string(),
- message.to_string(),
- )
+ format!("<{}>[{}]</{}> {}", style, section, style, message,)
}
/// Formats a message as a block of text.
@@ -66,12 +60,7 @@ impl FormatterHelper {
let mut i = 0;
while i < messages.len() {
- messages[i] = format!(
- "<{}>{}</{}>",
- style.to_string(),
- messages[i].clone(),
- style.to_string(),
- );
+ messages[i] = format!("<{}>{}</{}>", style, messages[i].clone(), style,);
i += 1;
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
index c59eed0..10fff08 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
@@ -4,7 +4,6 @@ use crate::symfony::console::helper::debug_formatter_helper::DebugFormatterHelpe
use crate::symfony::console::helper::helper::Helper;
use crate::symfony::console::helper::helper_interface::HelperInterface;
use crate::symfony::console::helper::helper_set::HelperSet;
-use crate::symfony::console::output::console_output_interface::ConsoleOutputInterface;
use crate::symfony::console::output::output_interface::{self, OutputInterface};
use crate::symfony::process::exception::process_failed_exception::ProcessFailedException;
use crate::symfony::process::process::Process;
@@ -221,7 +220,8 @@ impl ProcessHelper {
&self,
output: Rc<RefCell<dyn OutputInterface>>,
process: &Process,
- mut callback: Option<Box<dyn FnMut(&str, &str)>>,
+ // TODO: remove allow(unused_mut) once todo!() is resolved.
+ #[allow(unused_mut)] mut callback: Option<Box<dyn FnMut(&str, &str)>>,
) -> Box<dyn FnMut(&str, &str)> {
// PHP: `if ($output instanceof ConsoleOutputInterface) { $output =
// $output->getErrorOutput(); }`. Downcasting a shared `dyn
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
index ab97d2e..aa7e326 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
@@ -584,7 +584,7 @@ impl ProgressBar {
Box::new(
|bar: &ProgressBar, output: &Rc<RefCell<dyn OutputInterface>>| {
let complete_bars = bar.get_bar_offset();
- let mut display = shirabe_php_shim::str_repeat(
+ let display = shirabe_php_shim::str_repeat(
&bar.get_bar_character(),
complete_bars as usize,
);
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
index 281069e..b6d096a 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
@@ -19,7 +19,6 @@ use crate::symfony::console::question::ChoiceQuestion;
use crate::symfony::console::question::QuestionInterface;
use crate::symfony::console::terminal::Terminal;
use crate::symfony::string::s;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
@@ -126,10 +125,23 @@ impl QuestionHelper {
let autocomplete = question.get_autocompleter_callback();
let ret: PhpMixed;
- if autocomplete.is_none()
- || !STTY.load(std::sync::atomic::Ordering::SeqCst)
- || !Terminal::has_stty_available()
+
+ if let Some(autocomplete) = autocomplete
+ && STTY.load(std::sync::atomic::Ordering::SeqCst)
+ && Terminal::has_stty_available()
{
+ let callback = autocomplete;
+ // The autocompleter callback yields an iterable (Option here); PHP
+ // treats a null result as an empty list of suggestions.
+ let callback = move |input: &str| callback(input).unwrap_or_default();
+ let autocomplete =
+ self.autocomplete(Rc::clone(&output), question, &input_stream, &callback);
+ ret = PhpMixed::String(if question.is_trimmable() {
+ shirabe_php_shim::trim(&autocomplete, None)
+ } else {
+ autocomplete
+ });
+ } else {
let mut r: PhpMixed = PhpMixed::Bool(false);
if question.is_hidden() {
match self.get_hidden_response(
@@ -182,18 +194,6 @@ impl QuestionHelper {
}
}
ret = r;
- } else {
- let callback = autocomplete.unwrap();
- // The autocompleter callback yields an iterable (Option here); PHP
- // treats a null result as an empty list of suggestions.
- let callback = move |input: &str| callback(input).unwrap_or_default();
- let autocomplete =
- self.autocomplete(Rc::clone(&output), question, &input_stream, &callback);
- ret = PhpMixed::String(if question.is_trimmable() {
- shirabe_php_shim::trim(&autocomplete, None)
- } else {
- autocomplete
- });
}
let mut ret = ret;
@@ -318,12 +318,12 @@ impl QuestionHelper {
) {
let message = if let Some(helper_set) = self.get_helper_set() {
let formatter = helper_set.borrow().get_formatter();
- let message = formatter.borrow().format_block(
+
+ formatter.borrow().format_block(
FormatBlockMessages::String(error.message.clone()),
"error",
false,
- );
- message
+ )
} else {
format!("<error>{}</error>", error.message)
};
@@ -476,7 +476,6 @@ impl QuestionHelper {
)
})
.collect();
- num_matches = matches.len() as i64;
ofs = -1;
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs
index ea7a322..a5118f4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs
@@ -6,7 +6,6 @@ use crate::symfony::console::output::output_interface;
use crate::symfony::console::output::output_interface::OutputInterface;
use crate::symfony::console::question::QuestionInterface;
use crate::symfony::console::style::symfony_style::SymfonyStyle;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
@@ -46,8 +45,7 @@ impl SymfonyQuestionHelper {
"yes"
} else {
"no"
- }
- .to_string(),
+ },
);
} else if let Some(choice_question) = question.as_choice().filter(|q| q.is_multiselect()) {
let choices = choice_question.get_choices();
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
index 59da457..04d5f1f 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
@@ -14,7 +14,6 @@ use crate::symfony::console::helper::table_style::TableStyle;
use crate::symfony::console::output::console_section_output::ConsoleSectionOutput;
use crate::symfony::console::output::output_interface::OutputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
@@ -509,8 +508,7 @@ impl Table {
/// Renders table to output.
pub fn render(&mut self) {
- let rows: Vec<Row>;
- if self.horizontal {
+ let rows: Vec<Row> = if self.horizontal {
let mut horizontal_rows: IndexMap<i64, Vec<Cell>> = IndexMap::new();
let header0 = self.headers.first().map(|h| h.cells()).unwrap_or_default();
for (i, header) in header0.into_iter().enumerate() {
@@ -538,13 +536,13 @@ impl Table {
}
}
}
- rows = horizontal_rows.into_values().map(Row::Cells).collect();
+ horizontal_rows.into_values().map(Row::Cells).collect()
} else {
let mut merged = self.headers.clone();
merged.push(Row::HeaderDivider);
merged.extend(self.rows.clone());
- rows = merged;
- }
+ merged
+ };
self.calculate_number_of_columns(&rows);
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs
index 54a5f3a..c1a708a 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs
@@ -270,10 +270,10 @@ impl ArgvInput {
format!(
"No arguments expected for \"{}\" command, got \"{}\".",
symfony_command_name.clone().unwrap(),
- token.to_string(),
+ token,
)
} else {
- format!("No arguments expected, got \"{}\".", token.to_string())
+ format!("No arguments expected, got \"{}\".", token)
};
return Err(
@@ -288,7 +288,7 @@ impl ArgvInput {
fn add_short_option(&mut self, shortcut: &str, value: PhpMixed) -> anyhow::Result<()> {
if !self.inner.definition.has_shortcut(shortcut) {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!("The \"-{}\" option does not exist.", shortcut.to_string()),
+ message: format!("The \"-{}\" option does not exist.", shortcut),
code: 0,
})
.into());
@@ -308,7 +308,7 @@ impl ArgvInput {
if !self.inner.definition.has_option(name) {
if !self.inner.definition.has_negation(name) {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!("The \"--{}\" option does not exist.", name.to_string()),
+ message: format!("The \"--{}\" option does not exist.", name),
code: 0,
})
.into());
@@ -317,10 +317,7 @@ impl ArgvInput {
let option_name = self.inner.definition.negation_to_name(name)?;
if !matches!(value, PhpMixed::Null) {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!(
- "The \"--{}\" option does not accept a value.",
- name.to_string(),
- ),
+ message: format!("The \"--{}\" option does not accept a value.", name,),
code: 0,
})
.into());
@@ -336,10 +333,7 @@ impl ArgvInput {
if !matches!(value, PhpMixed::Null) && !option.accept_value() {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!(
- "The \"--{}\" option does not accept a value.",
- name.to_string(),
- ),
+ message: format!("The \"--{}\" option does not accept a value.", name,),
code: 0,
})
.into());
@@ -364,7 +358,7 @@ impl ArgvInput {
if matches!(value, PhpMixed::Null) {
if option.is_value_required() {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!("The \"--{}\" option requires a value.", name.to_string()),
+ message: format!("The \"--{}\" option requires a value.", name),
code: 0,
})
.into());
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs
index 384bc6d..051d8bd 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs
@@ -216,7 +216,7 @@ impl ArrayInput {
if !self.inner.definition.has_shortcut(shortcut) {
return Err(InvalidOptionException(InvalidArgumentException(
shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"-{}\" option does not exist.", shortcut.to_string()),
+ message: format!("The \"-{}\" option does not exist.", shortcut),
code: 0,
},
))
@@ -238,7 +238,7 @@ impl ArrayInput {
if !self.inner.definition.has_negation(name) {
return Err(InvalidOptionException(InvalidArgumentException(
shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"--{}\" option does not exist.", name.to_string()),
+ message: format!("The \"--{}\" option does not exist.", name),
code: 0,
},
))
@@ -257,18 +257,13 @@ impl ArrayInput {
if matches!(value, PhpMixed::Null) {
if option.is_value_required() {
- return Err(
- InvalidOptionException(InvalidArgumentException(
- shirabe_php_shim::InvalidArgumentException {
- message: format!(
- "The \"--{}\" option requires a value.",
- name.to_string(),
- ),
- code: 0,
- },
- ))
- .into(),
- );
+ return Err(InvalidOptionException(InvalidArgumentException(
+ shirabe_php_shim::InvalidArgumentException {
+ message: format!("The \"--{}\" option requires a value.", name,),
+ code: 0,
+ },
+ ))
+ .into());
}
if !option.is_value_optional() {
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input.rs b/crates/shirabe-external-packages/src/symfony/console/input/input.rs
index 5e5a12b..70b6185 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/input.rs
@@ -115,7 +115,7 @@ impl Input {
{
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" argument does not exist.", name.to_string()),
+ message: format!("The \"{}\" argument does not exist.", name),
code: 0,
})
.into(),
@@ -139,7 +139,7 @@ impl Input {
{
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" argument does not exist.", name.to_string()),
+ message: format!("The \"{}\" argument does not exist.", name),
code: 0,
})
.into(),
@@ -176,7 +176,7 @@ impl Input {
if !self.definition.has_option(name) {
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" option does not exist.", name.to_string()),
+ message: format!("The \"{}\" option does not exist.", name),
code: 0,
})
.into(),
@@ -200,7 +200,7 @@ impl Input {
} else if !self.definition.has_option(name) {
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" option does not exist.", name.to_string()),
+ message: format!("The \"{}\" option does not exist.", name),
code: 0,
})
.into(),
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs
index 56f685c..a1d3d30 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs
@@ -114,7 +114,7 @@ impl InputDefinition {
return Err(LogicException(shirabe_php_shim::LogicException {
message: format!(
"An argument with name \"{}\" already exists.",
- argument.get_name().to_string(),
+ argument.get_name(),
),
code: 0,
})
@@ -125,8 +125,8 @@ impl InputDefinition {
return Err(LogicException(shirabe_php_shim::LogicException {
message: format!(
"Cannot add a required argument \"{}\" after an array argument \"{}\".",
- argument.get_name().to_string(),
- last_array_argument.get_name().to_string(),
+ argument.get_name(),
+ last_array_argument.get_name(),
),
code: 0,
})
@@ -139,8 +139,8 @@ impl InputDefinition {
return Err(LogicException(shirabe_php_shim::LogicException {
message: format!(
"Cannot add a required argument \"{}\" after an optional one \"{}\".",
- argument.get_name().to_string(),
- last_optional_argument.get_name().to_string(),
+ argument.get_name(),
+ last_optional_argument.get_name(),
),
code: 0,
})
@@ -260,20 +260,14 @@ impl InputDefinition {
&& !option.equals(existing)
{
return Err(LogicException(shirabe_php_shim::LogicException {
- message: format!(
- "An option named \"{}\" already exists.",
- option.get_name().to_string(),
- ),
+ message: format!("An option named \"{}\" already exists.", option.get_name(),),
code: 0,
})
.into());
}
if self.negations.contains_key(option.get_name()) {
return Err(LogicException(shirabe_php_shim::LogicException {
- message: format!(
- "An option named \"{}\" already exists.",
- option.get_name().to_string(),
- ),
+ message: format!("An option named \"{}\" already exists.", option.get_name(),),
code: 0,
})
.into());
@@ -329,7 +323,7 @@ impl InputDefinition {
if !self.has_option(name) {
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"--{}\" option does not exist.", name.to_string()),
+ message: format!("The \"--{}\" option does not exist.", name),
code: 0,
})
.into(),
@@ -381,7 +375,7 @@ impl InputDefinition {
match self.shortcuts.get(shortcut) {
None => Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"-{}\" option does not exist.", shortcut.to_string()),
+ message: format!("The \"-{}\" option does not exist.", shortcut),
code: 0,
})
.into(),
@@ -395,7 +389,7 @@ impl InputDefinition {
match self.negations.get(negation) {
None => Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"--{}\" option does not exist.", negation.to_string()),
+ message: format!("The \"--{}\" option does not exist.", negation),
code: 0,
})
.into(),
@@ -432,19 +426,19 @@ impl InputDefinition {
let shortcut = match option.get_shortcut() {
Some(shortcut) => {
- format!("-{}|", shortcut.to_string())
+ format!("-{}|", shortcut)
}
None => String::new(),
};
let negation = if option.is_negatable() {
- format!("|--no-{}", option.get_name().to_string())
+ format!("|--no-{}", option.get_name())
} else {
String::new()
};
elements.push(format!(
"[{}--{}{}{}]",
shortcut,
- option.get_name().to_string(),
+ option.get_name(),
value,
negation,
));
diff --git a/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs b/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs
index 6c405a0..b42f2a4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs
@@ -25,8 +25,7 @@ impl TrimmedBufferOutput {
shirabe_php_shim::InvalidArgumentException {
message: format!(
"\"{}()\" expects a strictly positive maxLength. Got {}.",
- "Symfony\\Component\\Console\\Output\\TrimmedBufferOutput::__construct"
- .to_string(),
+ "Symfony\\Component\\Console\\Output\\TrimmedBufferOutput::__construct",
max_length,
),
code: 0,
diff --git a/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs b/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs
index 6c44966..a8cde91 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs
@@ -265,13 +265,13 @@ impl QuestionInterface for ChoiceQuestion {
self.inner.get_autocompleter_values()
}
- fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)> {
+ fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>> {
self.inner.get_autocompleter_callback()
}
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.inner.get_validator()
}
@@ -279,7 +279,7 @@ impl QuestionInterface for ChoiceQuestion {
self.inner.get_max_attempts()
}
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.inner.get_normalizer()
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs b/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs
index 74039d0..4a05046 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs
@@ -85,13 +85,13 @@ impl QuestionInterface for ConfirmationQuestion {
self.inner.get_autocompleter_values()
}
- fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)> {
+ fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>> {
self.inner.get_autocompleter_callback()
}
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.inner.get_validator()
}
@@ -99,7 +99,7 @@ impl QuestionInterface for ConfirmationQuestion {
self.inner.get_max_attempts()
}
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.inner.get_normalizer()
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/question/question.rs b/crates/shirabe-external-packages/src/symfony/console/question/question.rs
index 2ff5f62..a96c315 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/question.rs
@@ -26,15 +26,15 @@ pub trait QuestionInterface: std::fmt::Debug {
fn get_autocompleter_values(&self) -> Option<Vec<PhpMixed>>;
- fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)>;
+ fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>>;
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)>;
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>>;
fn get_max_attempts(&self) -> Option<i64>;
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)>;
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed>;
fn is_trimmable(&self) -> bool;
@@ -178,13 +178,13 @@ impl Question {
// array_merge(array_keys($values), array_values($values))
let mut merged: Vec<PhpMixed> =
array.keys().map(|k| PhpMixed::String(k.clone())).collect();
- merged.extend(array.values().map(|v| v.clone()));
+ merged.extend(array.values().cloned());
merged
} else {
// array_values($values)
match &values {
- PhpMixed::List(list) => list.iter().cloned().collect(),
- PhpMixed::Array(array) => array.values().map(|v| v.clone()).collect(),
+ PhpMixed::List(list) => list.to_vec(),
+ PhpMixed::Array(array) => array.values().cloned().collect(),
_ => unreachable!(),
}
};
@@ -200,7 +200,7 @@ impl Question {
// list/array elements, otherwise treat as an empty iterator.
let cached: Vec<PhpMixed> = match values {
PhpMixed::List(list) => list.into_iter().collect(),
- PhpMixed::Array(array) => array.into_values().map(|v| v).collect(),
+ PhpMixed::Array(array) => array.into_values().collect(),
_ => Vec::new(),
};
Some(Box::new(move |_input: &str| Some(cached.clone())))
@@ -212,7 +212,7 @@ impl Question {
}
/// Gets the callback function used for the autocompleter.
- pub fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)> {
+ pub fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>> {
self.autocompleter_callback.as_deref()
}
@@ -251,7 +251,7 @@ impl Question {
/// Gets the validator for the question.
pub fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.validator.as_deref()
}
@@ -299,7 +299,7 @@ impl Question {
/// Gets the normalizer for the response.
///
/// The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
- pub fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ pub fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.normalizer.as_deref()
}
@@ -352,13 +352,13 @@ impl QuestionInterface for Question {
self.get_autocompleter_values()
}
- fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)> {
+ fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>> {
self.get_autocompleter_callback()
}
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.get_validator()
}
@@ -366,7 +366,7 @@ impl QuestionInterface for Question {
self.get_max_attempts()
}
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.get_normalizer()
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
index 2f7c7cb..425c815 100644
--- a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
@@ -9,7 +9,6 @@ use crate::symfony::console::helper::ProgressBar;
use crate::symfony::console::helper::SymfonyQuestionHelper;
use crate::symfony::console::helper::Table;
use crate::symfony::console::helper::TableCell;
-use crate::symfony::console::helper::TableSeparator;
use crate::symfony::console::helper::table::{Cell, Row};
use crate::symfony::console::input::InputInterface;
use crate::symfony::console::output::ConsoleOutputInterface;
@@ -429,7 +428,7 @@ impl SymfonyStyle {
));
if let Some(style) = style {
- *line = format!("<{}>{}</>", style.to_string(), line.clone());
+ *line = format!("<{}>{}</>", style, line.clone());
}
}
@@ -722,8 +721,7 @@ impl StyleInterface for SymfonyStyle {
default: Option<PhpMixed>,
) -> PhpMixed {
let default = if let Some(default) = default {
- let values =
- shirabe_php_shim::array_flip(&PhpMixed::List(choices.iter().cloned().collect()));
+ let values = shirabe_php_shim::array_flip(&PhpMixed::List(choices.to_vec()));
// $default = $values[$default] ?? $default;
let resolved = match &values {
PhpMixed::Array(map) => map.get(&default.to_string()).cloned(),
diff --git a/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs b/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs
index ba5b764..3a1b1b0 100644
--- a/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs
+++ b/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs
@@ -721,10 +721,10 @@ impl Filesystem {
if scheme.is_none() || scheme.as_deref() == Some("file") || scheme.as_deref() == Some("gs")
{
if let Some(tmp_file) = shirabe_php_shim::tempnam(&hierarchy, prefix) {
- if let Some(scheme) = &scheme {
- if scheme != "gs" {
- return Ok(format!("{}://{}", scheme, tmp_file));
- }
+ if let Some(scheme) = &scheme
+ && scheme != "gs"
+ {
+ return Ok(format!("{}://{}", scheme, tmp_file));
}
return Ok(tmp_file);
}
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
index bafd146..43a6567 100644
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
@@ -15,7 +15,7 @@ pub struct AbstractPipes {
impl AbstractPipes {
pub fn new(input: PhpMixed) -> Self {
- let mut input_buffer = String::new();
+ let input_buffer;
let stored_input;
// TODO(plugin): `$input instanceof \Iterator` is not modeled. The PHP `is_resource($input)`
// branch never applies: a PhpMixed is never a resource, so input is never stored as-is here.
@@ -81,9 +81,7 @@ impl AbstractPipes {
let mut w: Vec<PhpResource> = vec![stdin.clone()];
// let's have a look if something changed in streams
- if php::stream_select(&mut r, &mut w, &mut e, 0, Some(0)).is_none() {
- return None;
- }
+ php::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?;
if !self.input_buffer.is_empty() {
let written = php::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize;
diff --git a/crates/shirabe-external-packages/src/symfony/process/process.rs b/crates/shirabe-external-packages/src/symfony/process/process.rs
index 1b58972..fbf2da7 100644
--- a/crates/shirabe-external-packages/src/symfony/process/process.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/process.rs
@@ -1045,28 +1045,26 @@ impl Process {
return Ok(());
}
- if let Some(timeout) = self.timeout {
- if timeout < php::microtime() - self.starttime.unwrap_or(0.0) {
- self.stop(0.0, None);
+ if let Some(timeout) = self.timeout
+ && timeout < php::microtime() - self.starttime.unwrap_or(0.0)
+ {
+ self.stop(0.0, None);
- return Err(ProcessTimedOutException::new(
- self,
- ProcessTimedOutException::TYPE_GENERAL,
- )
- .into());
- }
+ return Err(ProcessTimedOutException::new(
+ self,
+ ProcessTimedOutException::TYPE_GENERAL,
+ )
+ .into());
}
- if let Some(idle_timeout) = self.idle_timeout {
- if idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0) {
- self.stop(0.0, None);
+ if let Some(idle_timeout) = self.idle_timeout
+ && idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0)
+ {
+ self.stop(0.0, None);
- return Err(ProcessTimedOutException::new(
- self,
- ProcessTimedOutException::TYPE_IDLE,
- )
- .into());
- }
+ return Err(
+ ProcessTimedOutException::new(self, ProcessTimedOutException::TYPE_IDLE).into(),
+ );
}
Ok(())
@@ -1242,13 +1240,14 @@ impl Process {
self.cached_exit_code = exitcode;
}
- if let Some(cached) = self.cached_exit_code {
- if !running && exitcode == Some(-1) {
- self.process_information
- .as_mut()
- .unwrap()
- .insert("exitcode".to_string(), PhpMixed::Int(cached));
- }
+ if let Some(cached) = self.cached_exit_code
+ && !running
+ && exitcode == Some(-1)
+ {
+ self.process_information
+ .as_mut()
+ .unwrap()
+ .insert("exitcode".to_string(), PhpMixed::Int(cached));
}
}
@@ -1386,11 +1385,11 @@ impl Process {
if signaled && termsig > 0 {
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
self.exitcode = Some(128 + termsig);
- } else if self.is_sigchild_enabled() {
- if let Some(i) = self.process_information.as_mut() {
- i.insert("signaled".to_string(), PhpMixed::Bool(true));
- i.insert("termsig".to_string(), PhpMixed::Int(-1));
- }
+ } else if self.is_sigchild_enabled()
+ && let Some(i) = self.process_information.as_mut()
+ {
+ i.insert("signaled".to_string(), PhpMixed::Bool(true));
+ i.insert("termsig".to_string(), PhpMixed::Int(-1));
}
}
@@ -1659,13 +1658,11 @@ impl Process {
key, commandline
))
.into()),
- Some(v) if matches!(v, PhpMixed::Bool(false)) => {
- Err(InvalidArgumentException::new(format!(
- "Command line is missing a value for parameter \"{}\": {}",
- key, commandline
- ))
- .into())
- }
+ Some(PhpMixed::Bool(false)) => Err(InvalidArgumentException::new(format!(
+ "Command line is missing a value for parameter \"{}\": {}",
+ key, commandline
+ ))
+ .into()),
Some(v) => Ok(self.escape_argument(Some(&to_php_string(v)))),
}
},
diff --git a/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs b/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs
index ce67428..15a6cfc 100644
--- a/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs
+++ b/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs
@@ -157,7 +157,7 @@ fn php_wordwrap(text: &str, linelength: i64, breakchar: &str, docut: bool) -> St
out.extend_from_slice(&text[laststart as usize..lastspace as usize]);
out.extend_from_slice(breakchar);
laststart = lastspace + 1;
- lastspace = lastspace + 1;
+ lastspace += 1;
}
current += 1;
}