diff options
Diffstat (limited to 'crates/shirabe/src/command')
| -rw-r--r-- | crates/shirabe/src/command/audit_command.rs | 13 | ||||
| -rw-r--r-- | crates/shirabe/src/command/base_command.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/command/config_command.rs | 281 | ||||
| -rw-r--r-- | crates/shirabe/src/command/package_discovery_trait.rs | 32 | ||||
| -rw-r--r-- | crates/shirabe/src/command/search_command.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/src/command/show_command.rs | 84 | ||||
| -rw-r--r-- | crates/shirabe/src/command/suggests_command.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/command/update_command.rs | 11 |
8 files changed, 207 insertions, 233 deletions
diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index 27d594e7..082afdc2 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -17,7 +17,8 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, impl_php_class, implode, in_array, + InvalidArgumentException, PhpMixed, UnexpectedValueException, impl_php_class, implode, + in_array_strict, }; #[derive(Debug)] @@ -165,10 +166,12 @@ impl Command for AuditCommand { .as_string() .map(|s| s.to_string()); if abandoned.is_some() - && !in_array( - PhpMixed::String(abandoned.clone().unwrap()), - &PhpMixed::from(Auditor::ABANDONEDS.to_vec()), - true, + && !in_array_strict( + abandoned.clone().unwrap(), + &Auditor::ABANDONEDS + .iter() + .map(|s| PhpMixed::String(s.to_string())) + .collect::<Vec<_>>(), ) { return Err(InvalidArgumentException { diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index 41b8d0f8..7a66862e 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -28,7 +28,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpClass, PhpMixed, RuntimeException, - UnexpectedValueException, count, explode, in_array, is_string, + UnexpectedValueException, count, explode, in_array_strict, is_string, }; pub const SUCCESS: i64 = 0; @@ -663,7 +663,7 @@ impl BaseCommand for BaseCommandData { .iter() .map(|s| PhpMixed::String(s.to_string())) .collect(); - if !in_array(val.clone(), &PhpMixed::List(formats), true) { + if !in_array_strict(val.clone(), &formats) { return Err(InvalidArgumentException { message: format!( "--{} must be one of {}.", diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 129b6614..02e26582 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -24,9 +24,9 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, - escapeshellcmd, exec, explode, file_exists, impl_php_class, implode, in_array, is_array, - is_bool, is_dir, is_numeric, is_object, is_string, json_encode, php_regex, str_replace, strpos, - strtolower, system, touch, var_export, + escapeshellcmd, exec, explode, file_exists, impl_php_class, implode, in_array_loose, + in_array_strict, is_array, is_bool, is_dir, is_numeric, is_object, is_string, json_encode, + php_regex, str_replace, strpos, strtolower, system, touch, var_export, }; use shirabe_semver::VersionParser; @@ -470,7 +470,13 @@ impl Command for ConfigCommand { .as_array() .and_then(|a| a.get(&setting_key)) .is_some() - && in_array(setting_key.as_str().into(), &properties.into(), true) + && in_array_strict( + setting_key.as_str(), + &properties + .iter() + .map(|s| PhpMixed::String(s.to_string())) + .collect::<Vec<_>>(), + ) { value = raw_data .as_array() @@ -519,16 +525,14 @@ impl Command for ConfigCommand { let values: Vec<String> = setting_values; // what the user is trying to add/change let boolean_validator = |val: &PhpMixed| -> bool { - in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "true".to_string(), - "false".to_string(), - "1".to_string(), - "0".to_string(), - ] - .into(), - true, + in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("1".to_string()), + PhpMixed::String("0".to_string()), + ], ) }; let boolean_normalizer = |val: &PhpMixed| -> PhpMixed { @@ -879,10 +883,12 @@ impl Command for ConfigCommand { } // handle unsetting extra/suggest - if in_array( - setting_key.as_str().into(), - &vec!["suggest".to_string(), "extra".to_string()].into(), - true, + if in_array_strict( + setting_key.as_str(), + &[ + PhpMixed::String("suggest".to_string()), + PhpMixed::String("extra".to_string()), + ], ) && input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source @@ -938,14 +944,12 @@ impl Command for ConfigCommand { } // handle audit.ignore and audit.ignore-abandoned with --merge support - if in_array( - setting_key.as_str().into(), - &vec![ - "audit.ignore".to_string(), - "audit.ignore-abandoned".to_string(), - ] - .into(), - true, + if in_array_strict( + setting_key.as_str(), + &[ + PhpMixed::String("audit.ignore".to_string()), + PhpMixed::String("audit.ignore-abandoned".to_string()), + ], ) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source @@ -1090,16 +1094,14 @@ impl Command for ConfigCommand { .as_mut() .unwrap() .add_config_setting(&key, PhpMixed::Array(obj)); - } else if in_array( - matches[1].as_str().into(), - &vec![ - "github-oauth".to_string(), - "gitlab-oauth".to_string(), - "gitlab-token".to_string(), - "bearer".to_string(), - ] - .into(), - true, + } else if in_array_strict( + matches[1].as_str(), + &[ + PhpMixed::String("github-oauth".to_string()), + PhpMixed::String("gitlab-oauth".to_string()), + PhpMixed::String("gitlab-token".to_string()), + PhpMixed::String("bearer".to_string()), + ], ) { if 1 != values.len() { return Err(RuntimeException { @@ -1416,10 +1418,12 @@ impl ConfigCommand { let mut k = k; for (key, value) in &contents_arr { if k.is_none() - && !in_array( - key.as_str().into(), - &vec!["config".to_string(), "repositories".to_string()].into(), - true, + && !in_array_strict( + key.as_str(), + &[ + PhpMixed::String("config".to_string()), + PhpMixed::String("repositories".to_string()), + ], ) { continue; @@ -1667,16 +1671,14 @@ pub type ValidatorFn = Box<dyn Fn(&PhpMixed) -> PhpMixed>; pub type NormalizerFn = Box<dyn Fn(&PhpMixed) -> PhpMixed>; fn boolean_validator(val: &PhpMixed) -> PhpMixed { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "true".to_string(), - "false".to_string(), - "1".to_string(), - "0".to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("1".to_string()), + PhpMixed::String("0".to_string()), + ], )) } @@ -1713,10 +1715,13 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "preferred-install".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec!["auto".to_string(), "source".to_string(), "dist".to_string()].into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("auto".to_string()), + PhpMixed::String("source".to_string()), + PhpMixed::String("dist".to_string()), + ], )) }), Box::new(|val| val.clone()), @@ -1726,10 +1731,13 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "gitlab-protocol".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec!["git".to_string(), "http".to_string(), "https".to_string()].into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("git".to_string()), + PhpMixed::String("http".to_string()), + PhpMixed::String("https".to_string()), + ], )) }), Box::new(|val| val.clone()), @@ -1739,15 +1747,13 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "store-auths".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "true".to_string(), - "false".to_string(), - "prompt".to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("prompt".to_string()), + ], )) }), Box::new(|val| { @@ -1866,16 +1872,14 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "bin-compat".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "auto".to_string(), - "full".to_string(), - "proxy".to_string(), - "symlink".to_string(), - ] - .into(), - false, + PhpMixed::Bool(in_array_loose( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("auto".to_string()), + PhpMixed::String("full".to_string()), + PhpMixed::String("proxy".to_string()), + PhpMixed::String("symlink".to_string()), + ], )) }), Box::new(|val| val.clone()), @@ -1885,17 +1889,15 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "discard-changes".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "stash".to_string(), - "true".to_string(), - "false".to_string(), - "1".to_string(), - "0".to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("stash".to_string()), + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("1".to_string()), + PhpMixed::String("0".to_string()), + ], )) }), Box::new(|val| { @@ -1957,18 +1959,16 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "bump-after-update".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "dev".to_string(), - "no-dev".to_string(), - "true".to_string(), - "false".to_string(), - "1".to_string(), - "0".to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("dev".to_string()), + PhpMixed::String("no-dev".to_string()), + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("1".to_string()), + PhpMixed::String("0".to_string()), + ], )) }), Box::new(|val| { @@ -2037,17 +2037,15 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "platform-check".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "php-only".to_string(), - "true".to_string(), - "false".to_string(), - "1".to_string(), - "0".to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("php-only".to_string()), + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("1".to_string()), + PhpMixed::String("0".to_string()), + ], )) }), Box::new(|val| { @@ -2064,15 +2062,13 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "use-parent-dir".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "true".to_string(), - "false".to_string(), - "prompt".to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("true".to_string()), + PhpMixed::String("false".to_string()), + PhpMixed::String("prompt".to_string()), + ], )) }), Box::new(|val| { @@ -2089,15 +2085,13 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> "audit.abandoned".to_string(), ( Box::new(|val| { - PhpMixed::Bool(in_array( - val.as_string().unwrap_or("").into(), - &vec![ - Auditor::ABANDONED_IGNORE.to_string(), - Auditor::ABANDONED_REPORT.to_string(), - Auditor::ABANDONED_FAIL.to_string(), - ] - .into(), - true, + PhpMixed::Bool(in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String(Auditor::ABANDONED_IGNORE.to_string()), + PhpMixed::String(Auditor::ABANDONED_REPORT.to_string()), + PhpMixed::String(Auditor::ABANDONED_FAIL.to_string()), + ], )) }), Box::new(|val| val.clone()), @@ -2131,10 +2125,13 @@ fn build_multi_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> } if let Some(list) = vals.as_list() { for val in list { - if !in_array( - val.as_string().unwrap_or("").into(), - &vec!["git".to_string(), "https".to_string(), "ssh".to_string()].into(), - false, + if !in_array_loose( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("git".to_string()), + PhpMixed::String("https".to_string()), + PhpMixed::String("ssh".to_string()), + ], ) { return PhpMixed::String( "valid protocols include: git, https, ssh".to_string(), @@ -2180,16 +2177,14 @@ fn build_multi_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> } if let Some(list) = vals.as_list() { for val in list { - if !in_array( - val.as_string().unwrap_or("").into(), - &vec![ - "low".to_string(), - "medium".to_string(), - "high".to_string(), - "critical".to_string(), - ] - .into(), - true, + if !in_array_strict( + val.as_string().unwrap_or(""), + &[ + PhpMixed::String("low".to_string()), + PhpMixed::String("medium".to_string()), + PhpMixed::String("high".to_string()), + PhpMixed::String("critical".to_string()), + ], ) { return PhpMixed::String( "valid severities include: low, medium, high, critical".to_string(), diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index a1faff35..5c921e95 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -24,7 +24,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys, - array_slice, asort, explode, file_get_contents, implode, in_array, is_array, is_file, + array_slice, asort, explode, file_get_contents, implode, in_array_strict, is_array, is_file, is_numeric, json_decode, levenshtein, php_regex, strlen, strpos, trim, }; @@ -239,15 +239,12 @@ pub trait PackageDiscoveryTrait: BaseCommand { if !matches.is_empty() { // Remove existing packages from search results. matches.retain(|found_package| { - !in_array( - PhpMixed::String(found_package.name.clone()), - &PhpMixed::List( - existing_packages - .iter() - .map(|s| PhpMixed::String(s.clone())) - .collect(), - ), - true, + !in_array_strict( + found_package.name.clone(), + &existing_packages + .iter() + .map(|s| PhpMixed::String(s.clone())) + .collect::<Vec<_>>(), ) }); // PHP: $matches = array_values($matches); — already a Vec in Rust @@ -661,15 +658,12 @@ pub trait PackageDiscoveryTrait: BaseCommand { // Check for similar names/typos let similar = self.find_similar(name)?; if !similar.is_empty() { - if in_array( - PhpMixed::String(name.to_string()), - &PhpMixed::List( - similar - .iter() - .map(|s| PhpMixed::String(s.clone())) - .collect(), - ), - true, + if in_array_strict( + name.to_string(), + &similar + .iter() + .map(|s| PhpMixed::String(s.clone())) + .collect::<Vec<_>>(), ) { return Err(InvalidArgumentException { message: format!( diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index b0eabf80..0b675109 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -19,7 +19,7 @@ use shirabe_external_packages::symfony::console::formatter::OutputFormatter; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, impl_php_class, implode, in_array, preg_quote, substr, + InvalidArgumentException, PhpMixed, impl_php_class, implode, in_array_loose, preg_quote, substr, }; #[derive(Debug)] @@ -120,13 +120,12 @@ impl Command for SearchCommand { .as_string() .map(|s| s.to_string()) .unwrap_or_else(|| "text".to_string()); - if !in_array( - PhpMixed::String(format.clone()), - &PhpMixed::List(vec![ + if !in_array_loose( + format.clone(), + &[ PhpMixed::String("text".to_string()), PhpMixed::String("json".to_string()), - ]), - false, + ], ) { io.write_error(&format!( "Unsupported format \"{}\". See help for supported formats.", diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 77d81858..fb663d86 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -44,8 +44,8 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, - array_search, date, date_format_to_strftime, extension_loaded, impl_php_class, in_array, - php_regex, realpath, strtolower, version_compare, + array_search, date, date_format_to_strftime, extension_loaded, impl_php_class, in_array_loose, + in_array_strict, php_regex, realpath, strtolower, version_compare, }; use shirabe_semver::Semver; use shirabe_semver::constraint::AnyConstraint; @@ -303,13 +303,12 @@ impl Command for ShowCommand { .as_string() .unwrap_or("text") .to_string(); - if !in_array( - PhpMixed::String(format.clone()), - &PhpMixed::List(vec![ + if !in_array_loose( + format.clone(), + &[ PhpMixed::String("text".to_string()), PhpMixed::String("json".to_string()), - ]), - false, + ], ) { self.get_io().write_error(&format!( "Unsupported format \"{}\". See help for supported formats.", @@ -628,15 +627,13 @@ impl Command for ShowCommand { if let Some(ref pkg) = matched_package && input.borrow().get_option("direct")?.as_bool() == Some(true) - && !in_array( - PhpMixed::String(pkg.get_name()), - &PhpMixed::List( - self.get_root_requires() - .into_iter() - .map(PhpMixed::String) - .collect(), - ), - true, + && !in_array_strict( + pkg.get_name(), + &self + .get_root_requires() + .into_iter() + .map(PhpMixed::String) + .collect::<Vec<_>>(), ) { return Err(InvalidArgumentException { @@ -798,15 +795,12 @@ impl Command for ShowCommand { }); let mut array_tree: Vec<IndexMap<String, PhpMixed>> = Vec::new(); for package in packages.iter() { - if in_array( - PhpMixed::String(package.get_name()), - &PhpMixed::List( - root_requires - .iter() - .map(|s| PhpMixed::String(s.clone())) - .collect(), - ), - true, + if in_array_strict( + package.get_name(), + &root_requires + .iter() + .map(|s| PhpMixed::String(s.clone())) + .collect::<Vec<_>>(), ) { array_tree.push(self.generate_package_tree( package.clone(), @@ -911,12 +905,12 @@ impl Command for ShowCommand { if matches_filter { let matches_list = match &package_list_filter { None => true, - Some(list) => in_array( - PhpMixed::String(p.get_name()), - &PhpMixed::List( - list.iter().map(|s| PhpMixed::String(s.clone())).collect(), - ), - true, + Some(list) => in_array_strict( + p.get_name(), + &list + .iter() + .map(|s| PhpMixed::String(s.clone())) + .collect::<Vec<_>>(), ), }; if matches_list { @@ -1075,15 +1069,13 @@ impl Command for ShowCommand { ); package_view_data.insert( "direct-dependency".to_string(), - PhpMixed::Bool(in_array( - PhpMixed::String(package.get_name()), - &PhpMixed::List( - self.get_root_requires() - .into_iter() - .map(PhpMixed::String) - .collect(), - ), - true, + PhpMixed::Bool(in_array_strict( + package.get_name(), + &self + .get_root_requires() + .into_iter() + .map(PhpMixed::String) + .collect::<Vec<_>>(), )), ); if format != "json" @@ -2581,11 +2573,7 @@ impl ShowCommand { .unwrap_or("") .to_string(); - let circular_warn = if in_array( - PhpMixed::String(require_name.clone()), - &PhpMixed::List(current_tree.to_vec()), - true, - ) { + let circular_warn = if in_array_strict(require_name.clone(), ¤t_tree) { "(circular dependency aborted here)" } else { "" @@ -2635,11 +2623,7 @@ impl ShowCommand { PhpMixed::String(require.get_pretty_constraint().to_string()), ); - if !in_array( - PhpMixed::String(require_name.clone()), - &PhpMixed::List(current_tree.to_vec()), - true, - ) { + if !in_array_strict(require_name.clone(), ¤t_tree) { current_tree.push(PhpMixed::String(require_name.clone())); let deep_children = self.add_tree( require_name, diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs index 89df4546..5c73da9b 100644 --- a/crates/shirabe/src/command/suggests_command.rs +++ b/crates/shirabe/src/command/suggests_command.rs @@ -15,7 +15,7 @@ use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, empty, impl_php_class, in_array}; +use shirabe_php_shim::{PhpMixed, empty, impl_php_class, in_array_loose}; #[derive(Debug)] pub struct SuggestsCommand { @@ -169,7 +169,7 @@ impl Command for SuggestsCommand { composer.get_package().clone().into(); packages.push(root_pkg_as_base); for package in &packages { - if !empty(&filter) && !in_array(PhpMixed::String(package.get_name()), &filter, false) { + if !empty(&filter) && !in_array_loose(package.get_name(), filter.values()) { continue; } reporter.add_suggestions_from_package(package.clone()); diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index e5602763..e9bf34a9 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -34,7 +34,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_intersect, - array_keys, array_merge_map, array_search_in_vec, impl_php_class, in_array, php_regex, + array_keys, array_merge_map, array_search_in_vec, impl_php_class, in_array_strict, php_regex, strtolower, }; use shirabe_semver::Intervals; @@ -334,14 +334,13 @@ impl Command for UpdateCommand { // the arguments lock/nothing/mirrors are not package names but trigger a mirror update instead // they are further mutually exclusive with listing actual package names let filtered_packages: Vec<String> = array_filter(&packages, |package: &String| -> bool { - !in_array( - PhpMixed::String(package.clone()), - &PhpMixed::List(vec![ + !in_array_strict( + package.clone(), + &[ PhpMixed::String("lock".to_string()), PhpMixed::String("nothing".to_string()), PhpMixed::String("mirrors".to_string()), - ]), - true, + ], ) }); let update_mirrors = input |
