aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/package_discovery_trait.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-06 06:25:10 +0900
committernsfisis <nsfisis@gmail.com>2026-08-06 06:25:30 +0900
commit791ef1cd465597ff43dab4216c4b00e9e4160da8 (patch)
treeec6c3bc45f81576146325350faa6dcea638987b4 /crates/shirabe/src/command/package_discovery_trait.rs
parenta86bbd67954f7bbc38bb09138edb335d82666526 (diff)
downloadphp-shirabe-791ef1cd465597ff43dab4216c4b00e9e4160da8.tar.gz
php-shirabe-791ef1cd465597ff43dab4216c4b00e9e4160da8.tar.zst
php-shirabe-791ef1cd465597ff43dab4216c4b00e9e4160da8.zip
refactor(php-shim): split in_array into strict and loose variants
Diffstat (limited to 'crates/shirabe/src/command/package_discovery_trait.rs')
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs32
1 files changed, 13 insertions, 19 deletions
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!(