aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-external-packages')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/cursor.rs18
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/application_description.rs7
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/json_descriptor.rs64
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs12
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs17
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs2
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs8
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/array_input.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/input_option.rs2
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs22
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/question.rs10
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs39
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/terminal.rs15
13 files changed, 88 insertions, 132 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/cursor.rs b/crates/shirabe-external-packages/src/symfony/console/cursor.rs
index 8f12efe..9b031ab 100644
--- a/crates/shirabe-external-packages/src/symfony/console/cursor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/cursor.rs
@@ -196,19 +196,19 @@ impl Cursor {
"echo 1 >/dev/null",
&vec![
shirabe_php_shim::PhpMixed::List(vec![
- Box::new(shirabe_php_shim::PhpMixed::String("file".to_string())),
- Box::new(shirabe_php_shim::PhpMixed::String("/dev/tty".to_string())),
- Box::new(shirabe_php_shim::PhpMixed::String("r".to_string())),
+ shirabe_php_shim::PhpMixed::String("file".to_string()),
+ shirabe_php_shim::PhpMixed::String("/dev/tty".to_string()),
+ shirabe_php_shim::PhpMixed::String("r".to_string()),
]),
shirabe_php_shim::PhpMixed::List(vec![
- Box::new(shirabe_php_shim::PhpMixed::String("file".to_string())),
- Box::new(shirabe_php_shim::PhpMixed::String("/dev/tty".to_string())),
- Box::new(shirabe_php_shim::PhpMixed::String("w".to_string())),
+ shirabe_php_shim::PhpMixed::String("file".to_string()),
+ shirabe_php_shim::PhpMixed::String("/dev/tty".to_string()),
+ shirabe_php_shim::PhpMixed::String("w".to_string()),
]),
shirabe_php_shim::PhpMixed::List(vec![
- Box::new(shirabe_php_shim::PhpMixed::String("file".to_string())),
- Box::new(shirabe_php_shim::PhpMixed::String("/dev/tty".to_string())),
- Box::new(shirabe_php_shim::PhpMixed::String("w".to_string())),
+ shirabe_php_shim::PhpMixed::String("file".to_string()),
+ shirabe_php_shim::PhpMixed::String("/dev/tty".to_string()),
+ shirabe_php_shim::PhpMixed::String("w".to_string()),
]),
],
&mut pipes,
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/application_description.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/application_description.rs
index d30e6ad..33f6a8e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/application_description.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/application_description.rs
@@ -136,12 +136,7 @@ impl ApplicationDescription {
entry.insert("id".to_string(), PhpMixed::String(namespace.clone()));
entry.insert(
"commands".to_string(),
- PhpMixed::List(
- names
- .into_iter()
- .map(|n| Box::new(PhpMixed::String(n)))
- .collect(),
- ),
+ PhpMixed::List(names.into_iter().map(PhpMixed::String).collect()),
);
self.namespaces.as_mut().unwrap().insert(namespace, entry);
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/json_descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/json_descriptor.rs
index 9068a0a..381ee69 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/json_descriptor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/json_descriptor.rs
@@ -75,7 +75,7 @@ impl JsonDescriptor {
};
let mut description =
ApplicationDescription::new(application.clone(), described_namespace.clone(), true);
- let mut commands: Vec<Box<PhpMixed>> = vec![];
+ let mut commands: Vec<PhpMixed> = vec![];
let short = matches!(options.get("short"), Some(PhpMixed::Bool(true)));
let command_list: Vec<_> = description
@@ -84,25 +84,24 @@ impl JsonDescriptor {
.map(|c| c.borrow().clone_box())
.collect();
for mut command in command_list {
- commands.push(Box::new(PhpMixed::Array(
+ commands.push(PhpMixed::Array(
self.get_command_data(command.as_mut(), short)?
.into_iter()
- .map(|(k, v)| (k, Box::new(v)))
.collect(),
- )));
+ ));
}
let mut data: IndexMap<String, PhpMixed> = IndexMap::new();
if "UNKNOWN" != application.borrow().get_name() {
- let mut application_data: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
+ let mut application_data: IndexMap<String, PhpMixed> = IndexMap::new();
application_data.insert(
"name".to_string(),
- Box::new(PhpMixed::String(application.borrow().get_name())),
+ PhpMixed::String(application.borrow().get_name()),
);
if "UNKNOWN" != application.borrow().get_version() {
application_data.insert(
"version".to_string(),
- Box::new(PhpMixed::String(application.borrow().get_version())),
+ PhpMixed::String(application.borrow().get_version()),
);
}
data.insert("application".to_string(), PhpMixed::Array(application_data));
@@ -122,11 +121,7 @@ impl JsonDescriptor {
description
.get_namespaces()
.into_values()
- .map(|ns| {
- Box::new(PhpMixed::Array(
- ns.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
- ))
- })
+ .map(|ns| PhpMixed::Array(ns.into_iter().collect()))
.collect(),
),
);
@@ -148,11 +143,8 @@ impl JsonDescriptor {
};
self.write(
- &shirabe_php_shim::json_encode_ex(
- &PhpMixed::Array(data.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
- flags,
- )
- .unwrap_or_default(),
+ &shirabe_php_shim::json_encode_ex(&PhpMixed::Array(data.into_iter().collect()), flags)
+ .unwrap_or_default(),
false,
);
Ok(())
@@ -258,39 +250,36 @@ impl JsonDescriptor {
&self,
definition: &InputDefinition,
) -> anyhow::Result<IndexMap<String, PhpMixed>> {
- let mut input_arguments: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
+ let mut input_arguments: IndexMap<String, PhpMixed> = IndexMap::new();
for (name, argument) in definition.get_arguments() {
input_arguments.insert(
name.clone(),
- Box::new(PhpMixed::Array(
+ PhpMixed::Array(
self.get_input_argument_data(argument)?
.into_iter()
- .map(|(k, v)| (k, Box::new(v)))
.collect(),
- )),
+ ),
);
}
- let mut input_options: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
+ let mut input_options: IndexMap<String, PhpMixed> = IndexMap::new();
for (name, option) in definition.get_options() {
input_options.insert(
name.clone(),
- Box::new(PhpMixed::Array(
+ PhpMixed::Array(
self.get_input_option_data(option, false)?
.into_iter()
- .map(|(k, v)| (k, Box::new(v)))
.collect(),
- )),
+ ),
);
if option.is_negatable() {
input_options.insert(
format!("no-{}", name),
- Box::new(PhpMixed::Array(
+ PhpMixed::Array(
self.get_input_option_data(option, true)?
.into_iter()
- .map(|(k, v)| (k, Box::new(v)))
.collect(),
- )),
+ ),
);
}
}
@@ -326,26 +315,16 @@ impl JsonDescriptor {
command
.get_aliases()
.into_iter()
- .map(|a| Box::new(PhpMixed::String(a)))
+ .map(PhpMixed::String)
.collect(),
),
);
} else {
command.merge_application_definition(false);
- let mut usage = vec![Box::new(PhpMixed::String(command.get_synopsis(false)))];
- usage.extend(
- command
- .get_usages()
- .into_iter()
- .map(|u| Box::new(PhpMixed::String(u))),
- );
- usage.extend(
- command
- .get_aliases()
- .into_iter()
- .map(|a| Box::new(PhpMixed::String(a))),
- );
+ let mut usage = vec![PhpMixed::String(command.get_synopsis(false))];
+ usage.extend(command.get_usages().into_iter().map(PhpMixed::String));
+ usage.extend(command.get_aliases().into_iter().map(PhpMixed::String));
data.insert("usage".to_string(), PhpMixed::List(usage));
data.insert(
"help".to_string(),
@@ -356,7 +335,6 @@ impl JsonDescriptor {
PhpMixed::Array(
self.get_input_definition_data(command.get_definition())?
.into_iter()
- .map(|(k, v)| (k, Box::new(v)))
.collect(),
),
);
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 6590384..421cf52 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
@@ -342,7 +342,7 @@ impl TextDescriptor {
for namespace in namespaces.values() {
if let Some(PhpMixed::List(ns_commands)) = namespace.get("commands") {
for c in ns_commands {
- if let PhpMixed::String(name) = c.as_ref()
+ if let PhpMixed::String(name) = c
&& command_keys.contains(name)
{
merged.push(CommandOrString::String(name.clone()));
@@ -369,7 +369,7 @@ impl TextDescriptor {
let ns_commands: Vec<String> = match namespace.get("commands") {
Some(PhpMixed::List(names)) => names
.iter()
- .filter_map(|n| match n.as_ref() {
+ .filter_map(|n| match n {
PhpMixed::String(name) if commands.contains_key(name) => {
Some(name.clone())
}
@@ -467,8 +467,8 @@ impl TextDescriptor {
PhpMixed::Array(arr) => {
let mut arr = arr.clone();
for (_key, value) in arr.iter_mut() {
- if let PhpMixed::String(s) = value.as_ref() {
- **value = PhpMixed::String(OutputFormatter::escape(s)?);
+ if let PhpMixed::String(s) = &*value {
+ *value = PhpMixed::String(OutputFormatter::escape(s)?);
}
}
PhpMixed::Array(arr)
@@ -476,8 +476,8 @@ impl TextDescriptor {
PhpMixed::List(list) => {
let mut list = list.clone();
for value in list.iter_mut() {
- if let PhpMixed::String(s) = value.as_ref() {
- **value = PhpMixed::String(OutputFormatter::escape(s)?);
+ if let PhpMixed::String(s) = &*value {
+ *value = PhpMixed::String(OutputFormatter::escape(s)?);
}
}
PhpMixed::List(list)
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 1c01d70..c36f77a 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
@@ -155,7 +155,7 @@ impl QuestionHelper {
if matches!(r, PhpMixed::Bool(false)) {
let is_blocked = shirabe_php_shim::stream_get_meta_data(&input_stream)
.get("blocked")
- .map(|v| (**v).clone())
+ .cloned()
.unwrap_or(PhpMixed::Bool(true));
if !shirabe_php_shim::boolval(&is_blocked) {
@@ -236,23 +236,20 @@ impl QuestionHelper {
if !choice_question.is_multiselect() {
return choices
.get(&default.to_string())
- .map(|v| (**v).clone())
+ .cloned()
.unwrap_or(default);
}
let default_parts = shirabe_php_shim::explode(",", &default.to_string());
- let mut resolved: indexmap::IndexMap<String, Box<PhpMixed>> = indexmap::IndexMap::new();
+ let mut resolved: indexmap::IndexMap<String, PhpMixed> = indexmap::IndexMap::new();
for (k, v) in default_parts.iter().enumerate() {
let v = if question.is_trimmable() {
shirabe_php_shim::trim(v, None)
} else {
v.clone()
};
- let value = choices
- .get(&v)
- .map(|value| (**value).clone())
- .unwrap_or(PhpMixed::String(v));
- resolved.insert(k.to_string(), Box::new(value));
+ let value = choices.get(&v).cloned().unwrap_or(PhpMixed::String(v));
+ resolved.insert(k.to_string(), value);
}
return PhpMixed::Array(resolved);
@@ -306,7 +303,7 @@ impl QuestionHelper {
messages.push(format!(
" [<{tag}>{}{padding}</{tag}>] {}",
PhpMixed::String(key.clone()),
- (**value).clone(),
+ value.clone(),
));
}
@@ -849,7 +846,7 @@ impl QuestionHelper {
let stream_meta_data = shirabe_php_shim::stream_get_meta_data(input_stream);
let seekable = stream_meta_data
.get("seekable")
- .map(|v| (**v).clone())
+ .cloned()
.unwrap_or(PhpMixed::Bool(false));
let mode = stream_meta_data
.get("mode")
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 618398b..c1d8455 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
@@ -92,7 +92,7 @@ impl SymfonyQuestionHelper {
OutputFormatter::escape(
&choices
.get(&default.to_string())
- .map(|v| (**v).clone())
+ .cloned()
.unwrap_or(default.clone())
.to_string(),
)
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 d3df9aa..d7ddafc 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
@@ -211,7 +211,7 @@ impl ArgvInput {
if self.inner.definition.has_argument(&PhpMixed::Int(c)) {
let arg = self.inner.definition.get_argument(&PhpMixed::Int(c))?;
let value = if arg.is_array() {
- PhpMixed::List(vec![Box::new(PhpMixed::String(token.to_string()))])
+ PhpMixed::List(vec![PhpMixed::String(token.to_string())])
} else {
PhpMixed::String(token.to_string())
};
@@ -229,7 +229,7 @@ impl ArgvInput {
{
let arg = self.inner.definition.get_argument(&PhpMixed::Int(c - 1))?;
if let Some(PhpMixed::List(list)) = self.inner.arguments.get_mut(arg.get_name()) {
- list.push(Box::new(PhpMixed::String(token.to_string())));
+ list.push(PhpMixed::String(token.to_string()));
}
// unexpected argument
@@ -390,12 +390,12 @@ impl ArgvInput {
if option.is_array() {
match self.inner.options.get_mut(name) {
Some(PhpMixed::List(list)) => {
- list.push(Box::new(value));
+ list.push(value);
}
_ => {
self.inner
.options
- .insert(name.to_string(), PhpMixed::List(vec![Box::new(value)]));
+ .insert(name.to_string(), PhpMixed::List(vec![value]));
}
}
} else {
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 cad26e8..3fc9abb 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
@@ -378,8 +378,8 @@ impl InputInterface for ArrayInput {
/// PHP `(array) $values` cast: a string becomes a single-element array.
fn to_array(values: PhpMixed) -> Vec<PhpMixed> {
match values {
- PhpMixed::List(list) => list.into_iter().map(|v| *v).collect(),
- PhpMixed::Array(array) => array.into_iter().map(|(_, v)| *v).collect(),
+ PhpMixed::List(list) => list.into_iter().collect(),
+ PhpMixed::Array(array) => array.into_iter().map(|(_, v)| v).collect(),
PhpMixed::Null => vec![],
other => vec![other],
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input_option.rs b/crates/shirabe-external-packages/src/symfony/console/input/input_option.rs
index a90bff0..bd93f49 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/input_option.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/input_option.rs
@@ -52,7 +52,7 @@ impl InputOption {
let parts: Vec<String> = arr
.iter()
.filter_map(|v| {
- if let PhpMixed::String(s) = v.as_ref() {
+ if let PhpMixed::String(s) = v {
Some(s.clone())
} else {
None
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 e1368e5..64f0687 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
@@ -10,7 +10,7 @@ use shirabe_php_shim::PhpMixed;
#[derive(Debug)]
pub struct ChoiceQuestion {
inner: Question,
- choices: IndexMap<String, Box<PhpMixed>>,
+ choices: IndexMap<String, PhpMixed>,
multiselect: bool,
prompt: String,
error_message: String,
@@ -22,7 +22,7 @@ impl ChoiceQuestion {
/// `$default` The default answer to return.
pub fn new(
question: String,
- choices: IndexMap<String, Box<PhpMixed>>,
+ choices: IndexMap<String, PhpMixed>,
default: Option<PhpMixed>,
) -> Result<Self, LogicException> {
if choices.is_empty() {
@@ -44,14 +44,14 @@ impl ChoiceQuestion {
this.inner.set_validator(Some(validator));
// setAutocompleterValues never throws for an array argument.
this.inner
- .set_autocompleter_values(Some(PhpMixed::Array(choices)))
+ .set_autocompleter_values(Some(PhpMixed::Array(choices.clone())))
.expect("autocompleter cannot be set on a hidden question during construction");
Ok(this)
}
/// Returns available choices.
- pub fn get_choices(&self) -> &IndexMap<String, Box<PhpMixed>> {
+ pub fn get_choices(&self) -> &IndexMap<String, PhpMixed> {
&self.choices
}
@@ -151,7 +151,7 @@ impl ChoiceQuestion {
for value in &selected_choices {
let mut results: Vec<String> = Vec::new();
for (key, choice) in &choices {
- if (**choice) == *value {
+ if (*choice) == *value {
results.push(key.clone());
}
}
@@ -178,10 +178,10 @@ impl ChoiceQuestion {
if !is_assoc {
if let Some(found_key) = &result_key {
// $result = $choices[$result];
- result = (*choices[found_key]).clone();
+ result = choices[found_key].clone();
} else if let Some(found) = choices.get(&shirabe_php_shim::strval(value)) {
// isset($choices[$value])
- result = (**found).clone();
+ result = found.clone();
} else {
result = PhpMixed::Bool(false);
}
@@ -218,13 +218,11 @@ impl ChoiceQuestion {
}
if multiselect {
- return Ok(PhpMixed::List(
- multiselect_choices.into_iter().map(Box::new).collect(),
- ));
+ return Ok(PhpMixed::List(multiselect_choices));
}
Ok(shirabe_php_shim::current(PhpMixed::List(
- multiselect_choices.into_iter().map(Box::new).collect(),
+ multiselect_choices,
)))
})
}
@@ -232,7 +230,7 @@ impl ChoiceQuestion {
/// array_search operates over the choice values as strings; this projects the
/// choices map's values into the string-keyed form the shim expects.
-fn choices_as_str(choices: &IndexMap<String, Box<PhpMixed>>) -> IndexMap<String, String> {
+fn choices_as_str(choices: &IndexMap<String, PhpMixed>) -> IndexMap<String, String> {
choices
.iter()
.map(|(k, v)| (k.clone(), shirabe_php_shim::strval(v)))
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 78ae9b2..9ec3aef 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/question.rs
@@ -133,13 +133,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().map(|v| v.clone()));
merged
} else {
// array_values($values)
match &values {
- PhpMixed::List(list) => list.iter().map(|v| (**v).clone()).collect(),
- PhpMixed::Array(array) => array.values().map(|v| (**v).clone()).collect(),
+ PhpMixed::List(list) => list.iter().cloned().collect(),
+ PhpMixed::Array(array) => array.values().map(|v| v.clone()).collect(),
_ => unreachable!(),
}
};
@@ -154,8 +154,8 @@ impl Question {
// Non-array iterables are not modeled by PhpMixed; extract any
// list/array elements, otherwise treat as an empty iterator.
let cached: Vec<PhpMixed> = match values {
- PhpMixed::List(list) => list.into_iter().map(|v| *v).collect(),
- PhpMixed::Array(array) => array.into_values().map(|v| *v).collect(),
+ PhpMixed::List(list) => list.into_iter().collect(),
+ PhpMixed::Array(array) => array.into_values().map(|v| v).collect(),
_ => Vec::new(),
};
Some(Box::new(move |_input: &str| Some(cached.clone())))
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 3a04885..ce08f45 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
@@ -99,12 +99,7 @@ impl SymfonyStyle {
self.auto_prepend_block();
let block = self.create_block(messages, r#type, style, prefix, padding, escape);
self.writeln(
- PhpMixed::List(
- block
- .into_iter()
- .map(|line| Box::new(PhpMixed::String(line)))
- .collect(),
- ),
+ PhpMixed::List(block.into_iter().map(PhpMixed::String).collect()),
OUTPUT_NORMAL,
);
self.new_line(1);
@@ -181,10 +176,7 @@ impl SymfonyStyle {
row.push(shirabe_php_shim::current(value));
}
- self.horizontal_table(
- headers,
- vec![PhpMixed::List(row.into_iter().map(Box::new).collect())],
- );
+ self.horizontal_table(headers, vec![PhpMixed::List(row.into_iter().collect())]);
}
pub fn progress_iterate(
@@ -506,11 +498,11 @@ impl StyleInterface for SymfonyStyle {
self.auto_prepend_block();
self.writeln(
PhpMixed::List(vec![
- Box::new(PhpMixed::String(format!(
+ PhpMixed::String(format!(
"<comment>{}</>",
PhpMixed::String(OutputFormatter::escape_trailing_backslash(message),),
- ))),
- Box::new(PhpMixed::String(format!(
+ )),
+ PhpMixed::String(format!(
"<comment>{}</>",
PhpMixed::String(shirabe_php_shim::str_repeat(
"=",
@@ -519,7 +511,7 @@ impl StyleInterface for SymfonyStyle {
message,
)) as usize,
)),
- ))),
+ )),
]),
OUTPUT_NORMAL,
);
@@ -531,11 +523,11 @@ impl StyleInterface for SymfonyStyle {
self.auto_prepend_block();
self.writeln(
PhpMixed::List(vec![
- Box::new(PhpMixed::String(format!(
+ PhpMixed::String(format!(
"<comment>{}</>",
PhpMixed::String(OutputFormatter::escape_trailing_backslash(message),),
- ))),
- Box::new(PhpMixed::String(format!(
+ )),
+ PhpMixed::String(format!(
"<comment>{}</>",
PhpMixed::String(shirabe_php_shim::str_repeat(
"-",
@@ -544,7 +536,7 @@ impl StyleInterface for SymfonyStyle {
message,
)) as usize,
)),
- ))),
+ )),
]),
OUTPUT_NORMAL,
);
@@ -560,7 +552,7 @@ impl StyleInterface for SymfonyStyle {
);
self.writeln(
- PhpMixed::List(elements.into_iter().map(Box::new).collect()),
+ PhpMixed::List(elements.into_iter().collect()),
OUTPUT_NORMAL,
);
self.new_line(1);
@@ -698,9 +690,8 @@ 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().map(Box::new).collect(),
- ));
+ let values =
+ shirabe_php_shim::array_flip(&PhpMixed::List(choices.iter().cloned().collect()));
// $default = $values[$default] ?? $default;
let _ = values;
Some(default)
@@ -710,10 +701,10 @@ impl StyleInterface for SymfonyStyle {
// PHP: return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
// ChoiceQuestion extends Question; see `confirm` for the polymorphism note.
- let choices_map: indexmap::IndexMap<String, Box<PhpMixed>> = choices
+ let choices_map: indexmap::IndexMap<String, PhpMixed> = choices
.into_iter()
.enumerate()
- .map(|(i, c)| (i.to_string(), Box::new(c)))
+ .map(|(i, c)| (i.to_string(), c))
.collect();
let _choice_question = ChoiceQuestion::new(question.to_string(), choices_map, default);
self.ask_question(todo!())
diff --git a/crates/shirabe-external-packages/src/symfony/console/terminal.rs b/crates/shirabe-external-packages/src/symfony/console/terminal.rs
index 9ac1f9e..377d344 100644
--- a/crates/shirabe-external-packages/src/symfony/console/terminal.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/terminal.rs
@@ -210,12 +210,12 @@ impl Terminal {
let descriptorspec: Vec<PhpMixed> = vec![
PhpMixed::List(vec![
- Box::new(PhpMixed::String("pipe".to_string())),
- Box::new(PhpMixed::String("w".to_string())),
+ PhpMixed::String("pipe".to_string()),
+ PhpMixed::String("w".to_string()),
]),
PhpMixed::List(vec![
- Box::new(PhpMixed::String("pipe".to_string())),
- Box::new(PhpMixed::String("w".to_string())),
+ PhpMixed::String("pipe".to_string()),
+ PhpMixed::String("w".to_string()),
]),
];
@@ -248,13 +248,10 @@ impl Terminal {
/// Indexes into the `$pipes` array populated by proc_open.
fn php_pipe(pipes: &PhpMixed, index: i64) -> PhpMixed {
match pipes {
- PhpMixed::List(list) => list
- .get(index as usize)
- .map(|v| (**v).clone())
- .unwrap_or(PhpMixed::Null),
+ PhpMixed::List(list) => list.get(index as usize).cloned().unwrap_or(PhpMixed::Null),
PhpMixed::Array(array) => array
.get(&index.to_string())
- .map(|v| (**v).clone())
+ .map(|v| v.clone())
.unwrap_or(PhpMixed::Null),
_ => PhpMixed::Null,
}