aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-20 18:34:54 +0900
committernsfisis <nsfisis@gmail.com>2026-06-20 18:34:54 +0900
commit81b9fc9d92bb74aa8428ae4db39bd84e8c16095c (patch)
tree3efb6476d797e2a95545c4c3abba468c3e3c8d52 /crates/shirabe/src/command
parentc09cd630afb4bb0ca10e926f93bf706ca828ae85 (diff)
downloadphp-shirabe-81b9fc9d92bb74aa8428ae4db39bd84e8c16095c.tar.gz
php-shirabe-81b9fc9d92bb74aa8428ae4db39bd84e8c16095c.tar.zst
php-shirabe-81b9fc9d92bb74aa8428ae4db39bd84e8c16095c.zip
refactor(php-shim): drop Box wrapping from PhpMixed List/Array
The List and Array variants of PhpMixed boxed their elements unnecessarily. Store PhpMixed values directly and update all callers accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/base_command.rs6
-rw-r--r--crates/shirabe/src/command/base_config_command.rs5
-rw-r--r--crates/shirabe/src/command/base_dependency_command.rs9
-rw-r--r--crates/shirabe/src/command/bump_command.rs6
-rw-r--r--crates/shirabe/src/command/check_platform_reqs_command.rs38
-rw-r--r--crates/shirabe/src/command/config_command.rs127
-rw-r--r--crates/shirabe/src/command/create_project_command.rs9
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs56
-rw-r--r--crates/shirabe/src/command/init_command.rs48
-rw-r--r--crates/shirabe/src/command/licenses_command.rs56
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs4
-rw-r--r--crates/shirabe/src/command/remove_command.rs2
-rw-r--r--crates/shirabe/src/command/repository_command.rs13
-rw-r--r--crates/shirabe/src/command/require_command.rs16
-rw-r--r--crates/shirabe/src/command/run_script_command.rs4
-rw-r--r--crates/shirabe/src/command/search_command.rs4
-rw-r--r--crates/shirabe/src/command/show_command.rs125
-rw-r--r--crates/shirabe/src/command/suggests_command.rs2
-rw-r--r--crates/shirabe/src/command/update_command.rs10
19 files changed, 190 insertions, 350 deletions
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs
index c6b5550..40253d4 100644
--- a/crates/shirabe/src/command/base_command.rs
+++ b/crates/shirabe/src/command/base_command.rs
@@ -613,9 +613,9 @@ impl BaseCommand for BaseCommandData {
}
let val = input.borrow().get_option(opt_name)?;
- let formats: Vec<Box<PhpMixed>> = Auditor::FORMATS
+ let formats: Vec<PhpMixed> = Auditor::FORMATS
.iter()
- .map(|s| Box::new(PhpMixed::String(s.to_string())))
+ .map(|s| PhpMixed::String(s.to_string()))
.collect();
if !in_array(val.clone(), &PhpMixed::List(formats), true) {
return Err(InvalidArgumentException {
@@ -824,7 +824,7 @@ pub fn base_command_initialize(
PhpMixed::List(
explode(",", &ignore_str)
.into_iter()
- .map(|s| Box::new(PhpMixed::String(s)))
+ .map(PhpMixed::String)
.collect(),
),
);
diff --git a/crates/shirabe/src/command/base_config_command.rs b/crates/shirabe/src/command/base_config_command.rs
index 00098f2..01952f6 100644
--- a/crates/shirabe/src/command/base_config_command.rs
+++ b/crates/shirabe/src/command/base_config_command.rs
@@ -89,10 +89,7 @@ pub trait BaseConfigCommand: BaseCommand {
.borrow()
.write(PhpMixed::Array({
let mut m = IndexMap::new();
- m.insert(
- "config".to_string(),
- Box::new(PhpMixed::Array(IndexMap::new())),
- );
+ m.insert("config".to_string(), PhpMixed::Array(IndexMap::new()));
m
}))?;
let _ = Silencer::call(|| {
diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs
index 98a2622..6a892e8 100644
--- a/crates/shirabe/src/command/base_dependency_command.rs
+++ b/crates/shirabe/src/command/base_dependency_command.rs
@@ -111,7 +111,6 @@ pub trait BaseDependencyCommand: BaseCommand {
.cloned()
.unwrap_or_default()
.into_iter()
- .map(|(k, v)| (k, *v))
.collect();
repos.push(crate::repository::RepositoryInterfaceHandle::new(
PlatformRepository::new(vec![], platform_overrides)?,
@@ -379,13 +378,7 @@ pub trait BaseDependencyCommand: BaseCommand {
}
let table_as_mixed: Vec<PhpMixed> = table
.into_iter()
- .map(|row| {
- PhpMixed::List(
- row.into_iter()
- .map(|s| Box::new(PhpMixed::String(s)))
- .collect(),
- )
- })
+ .map(|row| PhpMixed::List(row.into_iter().map(PhpMixed::String).collect()))
.collect();
self.render_table(table_as_mixed, output);
}
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index 1d5a81d..17605d6 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -242,9 +242,9 @@ impl BumpCommand {
for (package, version) in packages {
let section = composer_definition
.entry(key.to_string())
- .or_insert_with(|| Box::new(PhpMixed::Array(indexmap::IndexMap::new())));
- if let PhpMixed::Array(map) = section.as_mut() {
- map.insert(package.clone(), Box::new(PhpMixed::String(version.clone())));
+ .or_insert_with(|| PhpMixed::Array(indexmap::IndexMap::new()));
+ if let PhpMixed::Array(map) = section {
+ map.insert(package.clone(), PhpMixed::String(version.clone()));
}
}
}
diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs
index bfd8b99..0f18557 100644
--- a/crates/shirabe/src/command/check_platform_reqs_command.rs
+++ b/crates/shirabe/src/command/check_platform_reqs_command.rs
@@ -72,65 +72,63 @@ impl CheckPlatformReqsCommand {
let mut row = IndexMap::new();
row.insert(
"name".to_string(),
- Box::new(PhpMixed::String(result.platform_package.clone())),
+ PhpMixed::String(result.platform_package.clone()),
);
row.insert(
"version".to_string(),
- Box::new(PhpMixed::String(result.version.clone())),
+ PhpMixed::String(result.version.clone()),
);
row.insert(
"status".to_string(),
- Box::new(PhpMixed::String(strip_tags(&result.status))),
+ PhpMixed::String(strip_tags(&result.status)),
);
if let Some(link) = &result.link {
let mut failed_req = IndexMap::new();
failed_req.insert(
"source".to_string(),
- Box::new(PhpMixed::String(link.get_source().to_string())),
+ PhpMixed::String(link.get_source().to_string()),
);
failed_req.insert(
"type".to_string(),
- Box::new(PhpMixed::String(link.get_description().to_string())),
+ PhpMixed::String(link.get_description().to_string()),
);
failed_req.insert(
"target".to_string(),
- Box::new(PhpMixed::String(link.get_target().to_string())),
+ PhpMixed::String(link.get_target().to_string()),
);
failed_req.insert(
"constraint".to_string(),
- Box::new(PhpMixed::String(link.get_pretty_constraint().to_string())),
+ PhpMixed::String(link.get_pretty_constraint().to_string()),
);
row.insert(
"failed_requirement".to_string(),
- Box::new(PhpMixed::Array(failed_req)),
+ PhpMixed::Array(failed_req),
);
} else {
- row.insert("failed_requirement".to_string(), Box::new(PhpMixed::Null));
+ row.insert("failed_requirement".to_string(), PhpMixed::Null);
}
let provider_str = strip_tags(&result.provider);
row.insert(
"provider".to_string(),
- Box::new(if provider_str.is_empty() {
+ if provider_str.is_empty() {
PhpMixed::Null
} else {
PhpMixed::String(provider_str)
- }),
+ },
);
PhpMixed::Array(row)
})
.collect();
- io.write(&JsonFile::encode(&PhpMixed::List(
- rows.into_iter().map(Box::new).collect(),
- )));
+ io.write(&JsonFile::encode(&PhpMixed::List(rows)));
} else {
let rows: Vec<PhpMixed> = results
.iter()
.map(|result| {
PhpMixed::List(vec![
- Box::new(PhpMixed::String(result.platform_package.clone())),
- Box::new(PhpMixed::String(result.version.clone())),
- Box::new(if let Some(link) = &result.link {
+ PhpMixed::String(result.platform_package.clone()),
+ PhpMixed::String(result.version.clone()),
+ if let Some(link) = &result.link {
PhpMixed::String(format!(
"{} {} {} ({})",
link.get_source(),
@@ -140,12 +138,12 @@ impl CheckPlatformReqsCommand {
))
} else {
PhpMixed::String(String::new())
- }),
- Box::new(PhpMixed::String(
+ },
+ PhpMixed::String(
format!("{} {}", result.status, result.provider)
.trim_end()
.to_string(),
- )),
+ ),
])
})
.collect();
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index 556dbdd..f6dffb7 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -178,7 +178,7 @@ impl Command for ConfigCommand {
&& !self.auth_config_file.as_ref().unwrap().borrow().exists()
{
touch(self.auth_config_file.as_ref().unwrap().borrow().get_path());
- let mut empty_objs: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
+ let mut empty_objs: IndexMap<String, PhpMixed> = IndexMap::new();
for k in &[
"bitbucket-oauth",
"github-oauth",
@@ -188,10 +188,7 @@ impl Command for ConfigCommand {
"bearer",
"forgejo-token",
] {
- empty_objs.insert(
- k.to_string(),
- Box::new(PhpMixed::Object(ArrayObject::new(None))),
- );
+ empty_objs.insert(k.to_string(), PhpMixed::Object(ArrayObject::new(None)));
}
self.auth_config_file
.as_ref()
@@ -274,10 +271,7 @@ impl Command for ConfigCommand {
if input.borrow().get_option("global")?.as_bool() != Some(true) {
let config_read = self.config_file.as_ref().unwrap().borrow_mut().read()?;
let config_map = match config_read {
- PhpMixed::Array(m) => m
- .into_iter()
- .map(|(k, v)| (k, *v))
- .collect::<IndexMap<String, PhpMixed>>(),
+ PhpMixed::Array(m) => m,
_ => IndexMap::new(),
};
self.config.as_mut().unwrap().borrow_mut().merge(
@@ -313,7 +307,7 @@ impl Command for ConfigCommand {
let all_map = self.config.as_ref().unwrap().borrow_mut().all(0)?;
let raw_map = self.config.as_ref().unwrap().borrow().raw();
let to_mixed = |m: IndexMap<String, PhpMixed>| -> PhpMixed {
- PhpMixed::Array(m.into_iter().map(|(k, v)| (k, Box::new(v))).collect())
+ PhpMixed::Array(m.into_iter().collect())
};
self.list_configuration(
to_mixed(all_map),
@@ -399,7 +393,7 @@ impl Command for ConfigCommand {
.as_ref()
.and_then(|r| r.as_array().and_then(|a| a.get(&repo_key)))
{
- Some(v) => (**v).clone(),
+ Some(v) => v.clone(),
None => {
return Err(InvalidArgumentException {
message: format!("There is no {} repository defined", repo_key),
@@ -430,7 +424,7 @@ impl Command for ConfigCommand {
&& let Some(v) = arr.get(&new_key)
{
r#match = true;
- cursor = (**v).clone();
+ cursor = v.clone();
key_acc = None;
}
}
@@ -478,11 +472,11 @@ impl Command for ConfigCommand {
.and_then(|a| a.get(&setting_key))
.and_then(|v| v.as_array())
.and_then(|a| a.get("type"))
- .map(|v| (**v).clone());
+ .cloned();
if let Some(tv) = type_value {
let type_array = match &tv {
PhpMixed::List(_) | PhpMixed::Array(_) => tv,
- other => PhpMixed::List(vec![Box::new(other.clone())]),
+ other => PhpMixed::List(vec![other.clone()]),
};
let type_strings: Vec<String> = type_array
.as_list()
@@ -503,7 +497,12 @@ impl Command for ConfigCommand {
.is_some()
&& in_array(setting_key.as_str().into(), &properties.into(), true)
{
- value = (**raw_data.as_array().unwrap().get(&setting_key).unwrap()).clone();
+ value = raw_data
+ .as_array()
+ .unwrap()
+ .get(&setting_key)
+ .unwrap()
+ .clone();
source = self
.config_file
.as_ref()
@@ -744,15 +743,9 @@ impl Command for ConfigCommand {
}
if 2 == values.len() {
- let mut repo: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- repo.insert(
- "type".to_string(),
- Box::new(PhpMixed::String(values[0].clone())),
- );
- repo.insert(
- "url".to_string(),
- Box::new(PhpMixed::String(values[1].clone())),
- );
+ let mut repo: IndexMap<String, PhpMixed> = IndexMap::new();
+ repo.insert("type".to_string(), PhpMixed::String(values[0].clone()));
+ repo.insert("url".to_string(), PhpMixed::String(values[1].clone()));
self.config_source.as_mut().unwrap().add_repository(
&matches[1],
PhpMixed::Array(repo),
@@ -820,7 +813,7 @@ impl Command for ConfigCommand {
current_value = current_value
.as_array()
.and_then(|a| a.get(bit))
- .map(|v| (**v).clone())
+ .cloned()
.unwrap_or(PhpMixed::Null);
}
if is_array(&current_value) && is_array(&value) {
@@ -833,7 +826,7 @@ impl Command for ConfigCommand {
);
} else {
// PHP "+" operator on arrays: keep keys from left, fill from right
- let mut merged: IndexMap<String, Box<PhpMixed>> =
+ let mut merged: IndexMap<String, PhpMixed> =
value.as_array().cloned().unwrap_or_default();
if let Some(cv) = current_value.as_array() {
for (k, v) in cv {
@@ -945,12 +938,8 @@ impl Command for ConfigCommand {
return Ok(0);
}
- let mut value: PhpMixed = PhpMixed::List(
- values
- .iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
- .collect(),
- );
+ let mut value: PhpMixed =
+ PhpMixed::List(values.iter().map(|s| PhpMixed::String(s.clone())).collect());
if input.borrow().get_option("json")?.as_bool() == Some(true) {
value = JsonFile::parse_json(Some(&values[0]), Some("composer.json"))?;
if !is_array(&value) {
@@ -972,7 +961,7 @@ impl Command for ConfigCommand {
.and_then(|a| a.get("audit"))
.and_then(|v| v.as_array())
.and_then(|a| a.get(&key_suffix))
- .map(|v| (**v).clone())
+ .cloned()
.unwrap_or(PhpMixed::Null);
if !current_value.is_null() && is_array(&current_value) && is_array(&value) {
@@ -984,7 +973,7 @@ impl Command for ConfigCommand {
);
} else if !array_is_list(&current_value) && !array_is_list(&value) {
// Both are associative arrays (objects), merge them
- let mut merged: IndexMap<String, Box<PhpMixed>> =
+ let mut merged: IndexMap<String, PhpMixed> =
value.as_array().cloned().unwrap_or_default();
if let Some(cv) = current_value.as_array() {
for (k, v) in cv {
@@ -1048,14 +1037,14 @@ impl Command for ConfigCommand {
.as_mut()
.unwrap()
.remove_config_setting(&key);
- let mut obj: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
+ let mut obj: IndexMap<String, PhpMixed> = IndexMap::new();
obj.insert(
"consumer-key".to_string(),
- Box::new(PhpMixed::String(values[0].clone())),
+ PhpMixed::String(values[0].clone()),
);
obj.insert(
"consumer-secret".to_string(),
- Box::new(PhpMixed::String(values[1].clone())),
+ PhpMixed::String(values[1].clone()),
);
self.auth_config_source
.as_mut()
@@ -1066,15 +1055,9 @@ impl Command for ConfigCommand {
.as_mut()
.unwrap()
.remove_config_setting(&key);
- let mut obj: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- obj.insert(
- "username".to_string(),
- Box::new(PhpMixed::String(values[0].clone())),
- );
- obj.insert(
- "token".to_string(),
- Box::new(PhpMixed::String(values[1].clone())),
- );
+ let mut obj: IndexMap<String, PhpMixed> = IndexMap::new();
+ obj.insert("username".to_string(), PhpMixed::String(values[0].clone()));
+ obj.insert("token".to_string(), PhpMixed::String(values[1].clone()));
self.auth_config_source
.as_mut()
.unwrap()
@@ -1120,15 +1103,9 @@ impl Command for ConfigCommand {
.as_mut()
.unwrap()
.remove_config_setting(&key);
- let mut obj: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- obj.insert(
- "username".to_string(),
- Box::new(PhpMixed::String(values[0].clone())),
- );
- obj.insert(
- "password".to_string(),
- Box::new(PhpMixed::String(values[1].clone())),
- );
+ let mut obj: IndexMap<String, PhpMixed> = IndexMap::new();
+ obj.insert("username".to_string(), PhpMixed::String(values[0].clone()));
+ obj.insert("password".to_string(), PhpMixed::String(values[1].clone()));
self.auth_config_source
.as_mut()
.unwrap()
@@ -1143,7 +1120,7 @@ impl Command for ConfigCommand {
}
// Validate headers format
- let mut formatted_headers: Vec<Box<PhpMixed>> = vec![];
+ let mut formatted_headers: Vec<PhpMixed> = vec![];
for header in &values {
if !is_string(&PhpMixed::String(header.clone())) {
return Err(RuntimeException {
@@ -1168,7 +1145,7 @@ impl Command for ConfigCommand {
.into());
}
- formatted_headers.push(Box::new(PhpMixed::String(header.clone())));
+ formatted_headers.push(PhpMixed::String(header.clone()));
}
self.config_source
@@ -1194,15 +1171,9 @@ impl Command for ConfigCommand {
.as_mut()
.unwrap()
.remove_config_setting(&key);
- let mut obj: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- obj.insert(
- "username".to_string(),
- Box::new(PhpMixed::String(values[0].clone())),
- );
- obj.insert(
- "token".to_string(),
- Box::new(PhpMixed::String(values[1].clone())),
- );
+ let mut obj: IndexMap<String, PhpMixed> = IndexMap::new();
+ obj.insert("username".to_string(), PhpMixed::String(values[0].clone()));
+ obj.insert("token".to_string(), PhpMixed::String(values[1].clone()));
self.auth_config_source
.as_mut()
.unwrap()
@@ -1225,12 +1196,7 @@ impl Command for ConfigCommand {
}
let value: PhpMixed = if values.len() > 1 {
- PhpMixed::List(
- values
- .iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
- .collect(),
- )
+ PhpMixed::List(values.iter().map(|s| PhpMixed::String(s.clone())).collect())
} else {
PhpMixed::String(values[0].clone())
};
@@ -1354,12 +1320,8 @@ impl ConfigCommand {
method: &str,
) -> anyhow::Result<()> {
let (validator, normalizer) = callbacks;
- let values_mixed = PhpMixed::List(
- values
- .iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
- .collect(),
- );
+ let values_mixed =
+ PhpMixed::List(values.iter().map(|s| PhpMixed::String(s.clone())).collect());
let validation = validator(&values_mixed);
if validation.as_bool() != Some(true) {
let suffix = if !validation.is_null() && validation.as_bool() != Some(false) {
@@ -1413,12 +1375,9 @@ impl ConfigCommand {
continue;
}
- let raw_val = raw_contents_arr
- .get(key)
- .map(|v| (**v).clone())
- .unwrap_or(PhpMixed::Null);
+ let raw_val = raw_contents_arr.get(key).cloned().unwrap_or(PhpMixed::Null);
- let value_inner = (**value).clone();
+ let value_inner = value.clone();
if is_array(&value_inner)
&& (!is_numeric(&key_first_key(&value_inner).unwrap_or_default().into())
@@ -2177,7 +2136,7 @@ fn flatten_setting_keys(config: PhpMixed, prefix: &str) -> Vec<String> {
// sub-keys of repository-keys must not be added to completion
if is_array(value) && !array_is_list(value) && prefix != "repositories." {
keys.push(flatten_setting_keys(
- (**value).clone(),
+ value.clone(),
&format!("{}{}.", prefix, key),
));
}
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index 3322008..c3c82d4 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -410,7 +410,7 @@ impl CreateProjectCommand {
PhpMixed::Array(
repo_config
.iter()
- .map(|(k, v)| (k.clone(), Box::new(v.clone())))
+ .map(|(k, v)| (k.clone(), v.clone()))
.collect(),
),
false,
@@ -698,9 +698,8 @@ impl CreateProjectCommand {
config.borrow_mut().set_base_dir(Some(directory.clone()));
if !secure_http {
let mut merge_map: indexmap::IndexMap<String, PhpMixed> = indexmap::IndexMap::new();
- let mut inner_map: indexmap::IndexMap<String, Box<PhpMixed>> =
- indexmap::IndexMap::new();
- inner_map.insert("secure-http".to_string(), Box::new(PhpMixed::Bool(false)));
+ let mut inner_map: indexmap::IndexMap<String, PhpMixed> = indexmap::IndexMap::new();
+ inner_map.insert("secure-http".to_string(), PhpMixed::Bool(false));
merge_map.insert("config".to_string(), PhpMixed::Array(inner_map));
config
.borrow_mut()
@@ -843,7 +842,7 @@ impl CreateProjectCommand {
.entry("options".to_string())
.or_insert(PhpMixed::Array(indexmap::IndexMap::new()));
if let PhpMixed::Array(options_map) = options_entry {
- options_map.insert("symlink".to_string(), Box::new(PhpMixed::Bool(false)));
+ options_map.insert("symlink".to_string(), PhpMixed::Bool(false));
}
}
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index 7f1aec5..739adad 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -144,8 +144,8 @@ impl Command for DiagnoseCommand {
ProcessExecutor::new(Some(io.clone())),
)));
}
- let mut config_inner: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- config_inner.insert("secure-http".to_string(), Box::new(PhpMixed::Bool(false)));
+ let mut config_inner = IndexMap::new();
+ config_inner.insert("secure-http".to_string(), PhpMixed::Bool(false));
let mut secure_http_wrap: IndexMap<String, PhpMixed> = IndexMap::new();
secure_http_wrap.insert("config".to_string(), PhpMixed::Array(config_inner));
let mut config = config;
@@ -187,10 +187,8 @@ impl Command for DiagnoseCommand {
.as_array()
.cloned()
.unwrap_or_default();
- let platform_overrides_unboxed: indexmap::IndexMap<String, PhpMixed> = platform_overrides
- .into_iter()
- .map(|(k, v)| (k, *v))
- .collect();
+ let platform_overrides_unboxed: indexmap::IndexMap<String, PhpMixed> =
+ platform_overrides.into_iter().collect();
let mut platform_repo =
PlatformRepository::new(vec![], platform_overrides_unboxed).unwrap();
let php_pkg = <PlatformRepository as crate::repository::RepositoryInterface>::find_package(
@@ -318,7 +316,7 @@ impl Command for DiagnoseCommand {
{
let repo_arr_unboxed: indexmap::IndexMap<String, PhpMixed> = repo_arr
.iter()
- .map(|(k, v)| (k.clone(), (**v).clone()))
+ .map(|(k, v)| (k.clone(), v.clone()))
.collect();
let composer_repo = ComposerRepository::new(
repo_arr_unboxed,
@@ -555,7 +553,7 @@ impl DiagnoseCommand {
return Ok(result);
}
- let mut result_list: Vec<Box<PhpMixed>> = vec![];
+ let mut result_list: Vec<PhpMixed> = vec![];
let mut tls_warning: Option<String> = None;
if proto == "https" && config.get("disable-tls").as_bool() == Some(true) {
tls_warning = Some("<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>".to_string());
@@ -571,15 +569,15 @@ impl DiagnoseCommand {
let hints = HttpDownloader::get_exception_hints(&e).unwrap_or_default();
if !hints.is_empty() {
for hint in hints {
- result_list.push(Box::new(PhpMixed::String(hint)));
+ result_list.push(PhpMixed::String(hint));
}
}
- result_list.push(Box::new(PhpMixed::String(format!(
+ result_list.push(PhpMixed::String(format!(
"<error>[{}] {}</error>",
std::any::type_name_of_val(te),
te.message
- ))));
+ )));
} else {
return Err(e);
}
@@ -587,7 +585,7 @@ impl DiagnoseCommand {
}
if let Some(w) = tls_warning {
- result_list.push(Box::new(PhpMixed::String(w)));
+ result_list.push(PhpMixed::String(w));
}
if !result_list.is_empty() {
@@ -603,7 +601,7 @@ impl DiagnoseCommand {
return Ok(result);
}
- let mut result_list: Vec<Box<PhpMixed>> = vec![];
+ let mut result_list: Vec<PhpMixed> = vec![];
let mut tls_warning: Option<String> = None;
if str_starts_with(url, "https://") && config.get("disable-tls").as_bool() == Some(true) {
tls_warning = Some("<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>".to_string());
@@ -622,15 +620,15 @@ impl DiagnoseCommand {
let hints = HttpDownloader::get_exception_hints(&e).unwrap_or_default();
if !hints.is_empty() {
for hint in hints {
- result_list.push(Box::new(PhpMixed::String(hint)));
+ result_list.push(PhpMixed::String(hint));
}
}
- result_list.push(Box::new(PhpMixed::String(format!(
+ result_list.push(PhpMixed::String(format!(
"<error>[{}] {}</error>",
std::any::type_name_of_val(te),
te.message
- ))));
+ )));
} else {
return Err(e);
}
@@ -638,7 +636,7 @@ impl DiagnoseCommand {
}
if let Some(w) = tls_warning {
- result_list.push(Box::new(PhpMixed::String(w)));
+ result_list.push(PhpMixed::String(w));
}
if !result_list.is_empty() {
@@ -682,12 +680,12 @@ impl DiagnoseCommand {
let first = provider_includes_arr
.values()
.next()
- .map(|v| (**v).clone())
+ .map(|v| v.clone())
.unwrap_or(PhpMixed::Null);
let hash_val = first
.as_array()
.and_then(|a| a.get("sha256"))
- .map(|v| (**v).clone())
+ .map(|v| v.clone())
.unwrap_or(PhpMixed::Null);
let path = str_replace(
"%hash%",
@@ -816,7 +814,7 @@ impl DiagnoseCommand {
.and_then(|a| a.get("resources"))
.and_then(|v| v.as_array())
.and_then(|a| a.get("core"))
- .map(|v| (**v).clone())
+ .map(|v| v.clone())
.unwrap_or(PhpMixed::Null))
}
@@ -848,7 +846,7 @@ impl DiagnoseCommand {
fn check_pub_keys(&mut self, config: &Config) -> anyhow::Result<PhpMixed> {
let home = config.get("home").as_string().unwrap_or("").to_string();
- let mut errors: Vec<Box<PhpMixed>> = vec![];
+ let mut errors: Vec<PhpMixed> = vec![];
let io = self.get_io();
if file_exists(&format!("{}/keys.tags.pub", home))
@@ -863,9 +861,9 @@ impl DiagnoseCommand {
Keys::fingerprint(&format!("{}/keys.tags.pub", home))?
));
} else {
- errors.push(Box::new(PhpMixed::String(
+ errors.push(PhpMixed::String(
"<error>Missing pubkey for tags verification</error>".to_string(),
- )));
+ ));
}
if file_exists(&format!("{}/keys.dev.pub", home)) {
@@ -874,15 +872,15 @@ impl DiagnoseCommand {
Keys::fingerprint(&format!("{}/keys.dev.pub", home))?
));
} else {
- errors.push(Box::new(PhpMixed::String(
+ errors.push(PhpMixed::String(
"<error>Missing pubkey for dev verification</error>".to_string(),
- )));
+ ));
}
if !errors.is_empty() {
- errors.push(Box::new(PhpMixed::String(
+ errors.push(PhpMixed::String(
"<error>Run composer self-update --update-keys to set them up</error>".to_string(),
- )));
+ ));
}
Ok(if !errors.is_empty() {
@@ -1109,7 +1107,7 @@ impl DiagnoseCommand {
had_error = true;
} else {
let result_list: Vec<PhpMixed> = match &result {
- PhpMixed::List(l) => l.iter().map(|b| (**b).clone()).collect(),
+ PhpMixed::List(l) => l.clone(),
other => vec![other.clone()],
};
for message in &result_list {
@@ -1121,7 +1119,7 @@ impl DiagnoseCommand {
}
}
// re-wrap so the final output loop works the same
- result = PhpMixed::List(result_list.into_iter().map(Box::new).collect());
+ result = PhpMixed::List(result_list);
}
if had_error {
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index d7beaf8..f58952e 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -137,12 +137,11 @@ impl Command for InitCommand {
"license".to_string(),
"autoload".to_string(),
];
- let filtered_input: IndexMap<String, Box<PhpMixed>> = array_intersect_key(
+ let filtered_input: IndexMap<String, PhpMixed> = array_intersect_key(
&input.borrow().get_options(),
&array_flip_strings(&allowlist),
)
.into_iter()
- .map(|(k, v)| (k, Box::new(v)))
.collect();
let mut options = shirabe_php_shim::array_filter_map(&filtered_input, |val: &PhpMixed| {
!matches!(val, PhpMixed::Null) && !matches!(val, PhpMixed::List(l) if l.is_empty())
@@ -178,11 +177,7 @@ impl Command for InitCommand {
PhpMixed::List(
self.format_authors(&author)?
.into_iter()
- .map(|m| {
- Box::new(PhpMixed::Array(
- m.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
- ))
- })
+ .map(|m| PhpMixed::Array(m.into_iter().collect()))
.collect(),
),
);
@@ -211,12 +206,7 @@ impl Command for InitCommand {
.entry("repositories".to_string())
.or_insert_with(|| PhpMixed::List(vec![]));
if let PhpMixed::List(list) = entry {
- list.push(Box::new(PhpMixed::Array(
- repo_config
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect(),
- )));
+ list.push(PhpMixed::Array(repo_config.into_iter().collect()));
}
}
}
@@ -244,7 +234,7 @@ impl Command for InitCommand {
PhpMixed::Array(
formatted
.into_iter()
- .map(|(k, v)| (k, Box::new(PhpMixed::String(v))))
+ .map(|(k, v)| (k, PhpMixed::String(v)))
.collect(),
)
}
@@ -271,7 +261,7 @@ impl Command for InitCommand {
PhpMixed::Array(
formatted
.into_iter()
- .map(|(k, v)| (k, Box::new(PhpMixed::String(v))))
+ .map(|(k, v)| (k, PhpMixed::String(v)))
.collect(),
)
};
@@ -294,19 +284,15 @@ impl Command for InitCommand {
.unwrap_or("")
.to_string();
let namespace = self.namespace_from_package_name(&name).unwrap_or_default();
- let mut psr4: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- psr4.insert(format!("{}\\", namespace), Box::new(PhpMixed::String(ap)));
- let mut autoload_obj: IndexMap<String, Box<PhpMixed>> = IndexMap::new();
- autoload_obj.insert("psr-4".to_string(), Box::new(PhpMixed::Array(psr4)));
+ let mut psr4 = IndexMap::new();
+ psr4.insert(format!("{}\\", namespace), PhpMixed::String(ap));
+ let mut autoload_obj = IndexMap::new();
+ autoload_obj.insert("psr-4".to_string(), PhpMixed::Array(psr4));
options.insert("autoload".to_string(), PhpMixed::Array(autoload_obj));
}
let file_obj = JsonFile::new(Factory::get_composer_file()?, None, None)?;
- let options_for_encode: IndexMap<String, Box<PhpMixed>> = options
- .clone()
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect();
+ let options_for_encode: IndexMap<String, PhpMixed> = options.clone().into_iter().collect();
let json = JsonFile::encode(&PhpMixed::Array(options_for_encode.clone()));
if input.borrow().is_interactive() {
@@ -823,12 +809,7 @@ impl Command for InitCommand {
};
input.borrow_mut().set_option(
"require",
- PhpMixed::List(
- requirements
- .into_iter()
- .map(|s| Box::new(PhpMixed::String(s)))
- .collect(),
- ),
+ PhpMixed::List(requirements.into_iter().map(PhpMixed::String).collect()),
);
let question = "Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ".to_string();
@@ -858,12 +839,7 @@ impl Command for InitCommand {
};
input.borrow_mut().set_option(
"require-dev",
- PhpMixed::List(
- dev_requirements
- .into_iter()
- .map(|s| Box::new(PhpMixed::String(s)))
- .collect(),
- ),
+ PhpMixed::List(dev_requirements.into_iter().map(PhpMixed::String).collect()),
);
// --autoload - input and validation
diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs
index 1f054d1..46cbd02 100644
--- a/crates/shirabe/src/command/licenses_command.rs
+++ b/crates/shirabe/src/command/licenses_command.rs
@@ -226,19 +226,18 @@ impl Command for LicensesCommand {
pkg_licenses.join(", ")
};
table.add_row(PhpMixed::List(vec![
- Box::new(PhpMixed::String(name)),
- Box::new(PhpMixed::String(package.get_full_pretty_version(
+ PhpMixed::String(name),
+ PhpMixed::String(package.get_full_pretty_version(
true,
crate::package::DisplayMode::SourceRefIfDev,
- ))),
- Box::new(PhpMixed::String(licenses_str)),
+ )),
+ PhpMixed::String(licenses_str),
]));
}
table.render();
}
"json" => {
- let mut dependencies: IndexMap<String, IndexMap<String, PhpMixed>> =
- IndexMap::new();
+ let mut dependencies: IndexMap<String, PhpMixed> = IndexMap::new();
for package in &packages {
let pkg_licenses = if let Some(complete_pkg) = package.as_complete_package() {
complete_pkg.get_license()
@@ -255,14 +254,12 @@ impl Command for LicensesCommand {
);
dep_info.insert(
"license".to_string(),
- PhpMixed::List(
- pkg_licenses
- .into_iter()
- .map(|l| Box::new(PhpMixed::String(l)))
- .collect(),
- ),
+ PhpMixed::List(pkg_licenses.into_iter().map(PhpMixed::String).collect()),
+ );
+ dependencies.insert(
+ package.get_pretty_name().to_string(),
+ PhpMixed::Array(dep_info),
);
- dependencies.insert(package.get_pretty_name().to_string(), dep_info);
}
let mut output_map: IndexMap<String, PhpMixed> = IndexMap::new();
@@ -283,34 +280,11 @@ impl Command for LicensesCommand {
let root_licenses = root.get_license();
output_map.insert(
"license".to_string(),
- PhpMixed::List(
- root_licenses
- .into_iter()
- .map(|l| Box::new(PhpMixed::String(l)))
- .collect(),
- ),
- );
- output_map.insert(
- "dependencies".to_string(),
- PhpMixed::Array(
- dependencies
- .into_iter()
- .map(|(k, v)| {
- (
- k,
- Box::new(PhpMixed::Array(
- v.into_iter().map(|(k2, v2)| (k2, Box::new(v2))).collect(),
- )),
- )
- })
- .collect(),
- ),
+ PhpMixed::List(root_licenses.into_iter().map(PhpMixed::String).collect()),
);
+ output_map.insert("dependencies".to_string(), PhpMixed::Array(dependencies));
io.write(&JsonFile::encode(&PhpMixed::Array(
- output_map
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect(),
+ output_map.into_iter().collect(),
)));
}
"summary" => {
@@ -336,8 +310,8 @@ impl Command for LicensesCommand {
.iter()
.map(|(license, count)| {
PhpMixed::List(vec![
- Box::new(PhpMixed::String(license.clone())),
- Box::new(PhpMixed::String(count.to_string())),
+ PhpMixed::String(license.clone()),
+ PhpMixed::String(count.to_string()),
])
})
.collect();
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index c182645..9be30f5 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -255,7 +255,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
&PhpMixed::List(
existing_packages
.iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
+ .map(|s| PhpMixed::String(s.clone()))
.collect(),
),
true,
@@ -678,7 +678,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
&PhpMixed::List(
similar
.iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
+ .map(|s| PhpMixed::String(s.clone()))
.collect(),
),
true,
diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs
index c1ba536..4260369 100644
--- a/crates/shirabe/src/command/remove_command.rs
+++ b/crates/shirabe/src/command/remove_command.rs
@@ -339,7 +339,7 @@ impl Command for RemoveCommand {
.filter_map(|(k, v)| v.as_string().map(|_| (k.clone(), k.clone())))
.collect();
for (name, canonical) in entries {
- section.insert(strtolower(&name), Box::new(PhpMixed::String(canonical)));
+ section.insert(strtolower(&name), PhpMixed::String(canonical));
}
}
}
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index 6ea26d2..caca808 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -84,7 +84,7 @@ impl RepositoryCommand {
}
if !packagist_present {
let mut packagist_entry = IndexMap::new();
- packagist_entry.insert("packagist.org".to_string(), Box::new(PhpMixed::Bool(false)));
+ packagist_entry.insert("packagist.org".to_string(), PhpMixed::Bool(false));
repos.insert(repos.len().to_string(), PhpMixed::Array(packagist_entry));
}
@@ -102,7 +102,7 @@ impl RepositoryCommand {
if let PhpMixed::Array(ref repo_map) = *repo {
if repo_map.len() == 1
&& let Some(first_val) = repo_map.values().next()
- && matches!(**first_val, PhpMixed::Bool(false))
+ && matches!(*first_val, PhpMixed::Bool(false))
{
let first_key = repo_map.keys().next().unwrap();
io.write(&format!("[{}] <info>disabled</info>", first_key));
@@ -273,7 +273,7 @@ impl Command for RepositoryCommand {
.get_path()
.to_string();
let config_data_map: IndexMap<String, PhpMixed> = match config_data {
- PhpMixed::Array(m) => m.into_iter().map(|(k, v)| (k, *v)).collect(),
+ PhpMixed::Array(m) => m.into_iter().collect(),
_ => IndexMap::new(),
};
self.config
@@ -312,11 +312,8 @@ impl Command for RepositoryCommand {
}));
}
let mut m = IndexMap::new();
- m.insert(
- "type".to_string(),
- Box::new(PhpMixed::String(arg1_str.to_string())),
- );
- m.insert("url".to_string(), Box::new(PhpMixed::String(arg2.unwrap())));
+ m.insert("type".to_string(), PhpMixed::String(arg1_str.to_string()));
+ m.insert("url".to_string(), PhpMixed::String(arg2.unwrap()));
PhpMixed::Array(m)
};
diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs
index a29f60d..f965350 100644
--- a/crates/shirabe/src/command/require_command.rs
+++ b/crates/shirabe/src/command/require_command.rs
@@ -284,7 +284,7 @@ impl Command for RequireCommand {
let platform_overrides = composer.get_config().borrow_mut().get("platform");
let platform_overrides_map: IndexMap<String, PhpMixed> = platform_overrides
.as_array()
- .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect())
+ .map(|m| m.iter().map(|(k, v)| (k.clone(), v.clone())).collect())
.unwrap_or_default();
// initialize self.repos as it is used by the PackageDiscoveryTrait
let platform_repo =
@@ -708,7 +708,7 @@ impl RequireCommand {
.and_then(|v| v.as_array())
{
for (k, v) in r {
- require.insert(k.clone(), (**v).clone());
+ require.insert(k.clone(), v.clone());
}
}
@@ -717,7 +717,7 @@ impl RequireCommand {
.and_then(|v| v.as_array())
{
for (k, v) in r {
- require_dev.insert(k.clone(), (**v).clone());
+ require_dev.insert(k.clone(), v.clone());
}
}
@@ -726,7 +726,7 @@ impl RequireCommand {
PhpMixed::List(
array_keys(&require)
.into_iter()
- .map(|k| Box::new(PhpMixed::String(k)))
+ .map(PhpMixed::String)
.collect(),
),
PhpMixed::String("require".to_string()),
@@ -735,7 +735,7 @@ impl RequireCommand {
PhpMixed::List(
array_keys(&require_dev)
.into_iter()
- .map(|k| Box::new(PhpMixed::String(k)))
+ .map(PhpMixed::String)
.collect(),
),
PhpMixed::String("require-dev".to_string()),
@@ -1196,16 +1196,16 @@ impl RequireCommand {
}
let composer_definition_mixed = json.borrow_mut().read().unwrap_or_default();
- let mut composer_definition: IndexMap<String, Box<PhpMixed>> = composer_definition_mixed
+ let mut composer_definition = composer_definition_mixed
.as_array()
.cloned()
.unwrap_or_default();
for (package, version) in new {
let section = composer_definition
.entry(require_key.to_string())
- .or_insert_with(|| Box::new(PhpMixed::Array(IndexMap::new())));
+ .or_insert_with(|| PhpMixed::Array(IndexMap::new()));
if let Some(section) = section.as_array_mut() {
- section.insert(package.clone(), Box::new(PhpMixed::String(version.clone())));
+ section.insert(package.clone(), PhpMixed::String(version.clone()));
}
if let Some(section) = composer_definition
.get_mut(remove_key)
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index 141b458..5a8f628 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -76,8 +76,8 @@ impl RunScriptCommand {
.iter()
.map(|(name, desc)| {
PhpMixed::List(vec![
- Box::new(PhpMixed::String(format!(" {}", name))),
- Box::new(PhpMixed::String(desc.clone())),
+ PhpMixed::String(format!(" {}", name)),
+ PhpMixed::String(desc.clone()),
])
})
.collect();
diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs
index 19a215f..c7070dd 100644
--- a/crates/shirabe/src/command/search_command.rs
+++ b/crates/shirabe/src/command/search_command.rs
@@ -126,8 +126,8 @@ impl Command for SearchCommand {
if !in_array(
PhpMixed::String(format.clone()),
&PhpMixed::List(vec![
- Box::new(PhpMixed::String("text".to_string())),
- Box::new(PhpMixed::String("json".to_string())),
+ PhpMixed::String("text".to_string()),
+ PhpMixed::String("json".to_string()),
]),
false,
) {
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index f7319ed..27ed8f1 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -202,8 +202,8 @@ impl Command for ShowCommand {
if !in_array(
PhpMixed::String(format.clone()),
&PhpMixed::List(vec![
- Box::new(PhpMixed::String("text".to_string())),
- Box::new(PhpMixed::String("json".to_string())),
+ PhpMixed::String("text".to_string()),
+ PhpMixed::String("json".to_string()),
]),
false,
) {
@@ -228,7 +228,7 @@ impl Command for ShowCommand {
.as_array()
.cloned()
{
- platform_overrides = p.into_iter().map(|(k, v)| (k, *v)).collect();
+ platform_overrides = p.into_iter().collect();
}
}
let platform_repo =
@@ -533,7 +533,7 @@ impl Command for ShowCommand {
&PhpMixed::List(
self.get_root_requires()
.into_iter()
- .map(|s| Box::new(PhpMixed::String(s)))
+ .map(PhpMixed::String)
.collect(),
),
true,
@@ -600,15 +600,10 @@ impl Command for ShowCommand {
let mut wrapper: IndexMap<String, PhpMixed> = IndexMap::new();
wrapper.insert(
"installed".to_string(),
- PhpMixed::List(vec![Box::new(PhpMixed::Array(
- array_tree
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect(),
- ))]),
+ PhpMixed::List(vec![PhpMixed::Array(array_tree.into_iter().collect())]),
);
self.get_io().write(&JsonFile::encode(&PhpMixed::Array(
- wrapper.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
+ wrapper.into_iter().collect(),
)));
} else {
self.display_package_tree(vec![array_tree]);
@@ -714,7 +709,7 @@ impl Command for ShowCommand {
&PhpMixed::List(
root_requires
.iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
+ .map(|s| PhpMixed::String(s.clone()))
.collect(),
),
true,
@@ -734,16 +729,12 @@ impl Command for ShowCommand {
PhpMixed::List(
array_tree
.into_iter()
- .map(|m| {
- Box::new(PhpMixed::Array(
- m.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
- ))
- })
+ .map(|m| PhpMixed::Array(m.into_iter().collect()))
.collect(),
),
);
self.get_io().write(&JsonFile::encode(&PhpMixed::Array(
- wrapper.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
+ wrapper.into_iter().collect(),
)));
} else {
self.display_package_tree(array_tree);
@@ -829,9 +820,7 @@ impl Command for ShowCommand {
Some(list) => in_array(
PhpMixed::String(p.get_name()),
&PhpMixed::List(
- list.iter()
- .map(|s| Box::new(PhpMixed::String(s.clone())))
- .collect(),
+ list.iter().map(|s| PhpMixed::String(s.clone())).collect(),
),
true,
),
@@ -997,7 +986,7 @@ impl Command for ShowCommand {
&PhpMixed::List(
self.get_root_requires()
.into_iter()
- .map(|s| Box::new(PhpMixed::String(s)))
+ .map(PhpMixed::String)
.collect(),
),
true,
@@ -1192,11 +1181,9 @@ impl Command for ShowCommand {
PhpMixed::List(
v.iter()
.map(|m| {
- Box::new(PhpMixed::Array(
- m.iter()
- .map(|(k, v)| (k.clone(), Box::new(v.clone())))
- .collect(),
- ))
+ PhpMixed::Array(
+ m.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
+ )
})
.collect(),
),
@@ -1204,10 +1191,7 @@ impl Command for ShowCommand {
}
let io = self.get_io();
io.write(&JsonFile::encode(&PhpMixed::Array(
- json_map
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect(),
+ json_map.into_iter().collect(),
)));
} else {
if input.borrow().get_option("latest")?.as_bool() == Some(true)
@@ -1804,7 +1788,7 @@ impl ShowCommand {
if r#type == "psr-0" || r#type == "psr-4" {
if let PhpMixed::Array(map) = autoloads {
for (name, path) in map.iter() {
- let path_str = match &**path {
+ let path_str = match &*path {
PhpMixed::List(l) => l
.iter()
.filter_map(|p| p.as_string().map(|s| s.to_string()))
@@ -1957,10 +1941,7 @@ impl ShowCommand {
.into_iter()
.map(PhpMixed::String)
.collect();
- json.insert(
- "keywords".to_string(),
- PhpMixed::List(keywords.into_iter().map(Box::new).collect()),
- );
+ json.insert("keywords".to_string(), PhpMixed::List(keywords));
json.insert(
"type".to_string(),
PhpMixed::String(package.get_type().to_string()),
@@ -1978,7 +1959,7 @@ impl ShowCommand {
package
.get_names(true)
.into_iter()
- .map(|n| Box::new(PhpMixed::String(n)))
+ .map(PhpMixed::String)
.collect(),
),
);
@@ -2012,7 +1993,7 @@ impl ShowCommand {
);
json.insert(
"source".to_string(),
- PhpMixed::Array(src.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
+ PhpMixed::Array(src.into_iter().collect()),
);
}
@@ -2032,7 +2013,7 @@ impl ShowCommand {
);
json.insert(
"dist".to_string(),
- PhpMixed::Array(dst.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
+ PhpMixed::Array(dst.into_iter().collect()),
);
}
@@ -2082,7 +2063,7 @@ impl ShowCommand {
}
json.insert(
"suggests".to_string(),
- PhpMixed::Array(s.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
+ PhpMixed::Array(s.into_iter().collect()),
);
}
@@ -2093,7 +2074,7 @@ impl ShowCommand {
}
json.insert(
"support".to_string(),
- PhpMixed::Array(s.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
+ PhpMixed::Array(s.into_iter().collect()),
);
}
@@ -2106,7 +2087,7 @@ impl ShowCommand {
package
.get_include_paths()
.into_iter()
- .map(|p| Box::new(PhpMixed::String(p)))
+ .map(PhpMixed::String)
.collect(),
),
);
@@ -2115,7 +2096,7 @@ impl ShowCommand {
json = Self::append_links(json, package);
self.get_io().write(&JsonFile::encode(&PhpMixed::Array(
- json.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
+ json.into_iter().collect(),
)));
Ok(())
}
@@ -2143,10 +2124,7 @@ impl ShowCommand {
.into_iter()
.map(|(k, _)| PhpMixed::String(k))
.collect();
- json.insert(
- "versions".to_string(),
- PhpMixed::List(keys.into_iter().map(Box::new).collect()),
- );
+ json.insert("versions".to_string(), PhpMixed::List(keys));
json
}
@@ -2183,15 +2161,12 @@ impl ShowCommand {
m.insert("name".to_string(), PhpMixed::String(name));
m.insert("osi".to_string(), PhpMixed::String(license_id));
m.insert("url".to_string(), PhpMixed::String(url));
- PhpMixed::Array(m.into_iter().map(|(k, v)| (k, Box::new(v))).collect())
+ PhpMixed::Array(m.into_iter().collect())
}
}
})
.collect();
- json.insert(
- "licenses".to_string(),
- PhpMixed::List(mapped.into_iter().map(Box::new).collect()),
- );
+ json.insert("licenses".to_string(), PhpMixed::List(mapped));
}
json
@@ -2211,7 +2186,7 @@ impl ShowCommand {
if let PhpMixed::Array(map) = autoloads {
for (name, path) in map.iter() {
- let mut path_val = (**path).clone();
+ let mut path_val = path.clone();
let is_empty_path = match &path_val {
PhpMixed::String(s) => s.is_empty(),
PhpMixed::Null => true,
@@ -2230,10 +2205,7 @@ impl ShowCommand {
}
}
- autoload.insert(
- r#type.clone(),
- PhpMixed::Array(psr.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
- );
+ autoload.insert(r#type.clone(), PhpMixed::Array(psr.into_iter().collect()));
} else if r#type == "classmap" {
autoload.insert("classmap".to_string(), autoloads.clone());
}
@@ -2241,12 +2213,7 @@ impl ShowCommand {
json.insert(
"autoload".to_string(),
- PhpMixed::Array(
- autoload
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect(),
- ),
+ PhpMixed::Array(autoload.into_iter().collect()),
);
}
@@ -2281,7 +2248,7 @@ impl ShowCommand {
}
json.insert(
link_type.to_string(),
- PhpMixed::Array(m.into_iter().map(|(k, v)| (k, Box::new(v))).collect()),
+ PhpMixed::Array(m.into_iter().collect()),
);
}
@@ -2378,7 +2345,7 @@ impl ShowCommand {
&PhpMixed::Array(
require
.iter()
- .map(|(k, v)| (k.clone(), Box::new((**v).clone())))
+ .map(|(k, v)| (k.clone(), v.clone()))
.collect(),
),
&packages_in_tree,
@@ -2432,22 +2399,13 @@ impl ShowCommand {
PhpMixed::List(
deep_children
.into_iter()
- .map(|m| {
- Box::new(PhpMixed::Array(
- m.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
- ))
- })
+ .map(|m| PhpMixed::Array(m.into_iter().collect()))
.collect(),
),
);
}
- children.push(PhpMixed::Array(
- tree_child_desc
- .into_iter()
- .map(|(k, v)| (k, Box::new(v)))
- .collect(),
- ));
+ children.push(PhpMixed::Array(tree_child_desc.into_iter().collect()));
}
let mut tree: IndexMap<String, PhpMixed> = IndexMap::new();
tree.insert(
@@ -2469,10 +2427,7 @@ impl ShowCommand {
);
if !children.is_empty() {
- tree.insert(
- "requires".to_string(),
- PhpMixed::List(children.into_iter().map(Box::new).collect()),
- );
+ tree.insert("requires".to_string(), PhpMixed::List(children));
}
tree
@@ -2524,7 +2479,7 @@ impl ShowCommand {
let circular_warn = if in_array(
PhpMixed::String(require_name.clone()),
- &PhpMixed::List(current_tree.iter().map(|v| Box::new(v.clone())).collect()),
+ &PhpMixed::List(current_tree.iter().cloned().collect()),
true,
) {
"(circular dependency aborted here)"
@@ -2578,7 +2533,7 @@ impl ShowCommand {
if !in_array(
PhpMixed::String(require_name.clone()),
- &PhpMixed::List(current_tree.iter().map(|v| Box::new(v.clone())).collect()),
+ &PhpMixed::List(current_tree.iter().cloned().collect()),
true,
) {
current_tree.push(PhpMixed::String(require_name.clone()));
@@ -2595,11 +2550,7 @@ impl ShowCommand {
PhpMixed::List(
deep_children
.into_iter()
- .map(|m| {
- Box::new(PhpMixed::Array(
- m.into_iter().map(|(k, v)| (k, Box::new(v))).collect(),
- ))
- })
+ .map(|m| PhpMixed::Array(m.into_iter().collect()))
.collect(),
),
);
diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs
index 8766196..eb4e05d 100644
--- a/crates/shirabe/src/command/suggests_command.rs
+++ b/crates/shirabe/src/command/suggests_command.rs
@@ -151,7 +151,7 @@ impl Command for SuggestsCommand {
let platform_cfg = composer.get_config().borrow().get("platform");
let platform_overrides: IndexMap<String, PhpMixed> = platform_cfg
.as_array()
- .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect())
+ .map(|m| m.iter().map(|(k, v)| (k.clone(), v.clone())).collect())
.unwrap_or_default();
installed_repos.push(RepositoryInterfaceHandle::new(PlatformRepository::new(
vec![],
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index 4581ce1..42622bd 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -308,9 +308,9 @@ impl Command for UpdateCommand {
!in_array(
PhpMixed::String(package.clone()),
&PhpMixed::List(vec![
- Box::new(PhpMixed::String("lock".to_string())),
- Box::new(PhpMixed::String("nothing".to_string())),
- Box::new(PhpMixed::String("mirrors".to_string())),
+ PhpMixed::String("lock".to_string()),
+ PhpMixed::String("nothing".to_string()),
+ PhpMixed::String("mirrors".to_string()),
]),
true,
)
@@ -700,9 +700,7 @@ impl UpdateCommand {
let mut table = Table::new(output);
table.set_headers(vec![PhpMixed::String("Selected packages".to_string())]);
for package in &packages {
- table.add_row(PhpMixed::List(vec![Box::new(PhpMixed::String(
- package.clone(),
- ))]));
+ table.add_row(PhpMixed::List(vec![PhpMixed::String(package.clone())]));
}
table.render();