From 791ef1cd465597ff43dab4216c4b00e9e4160da8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 6 Aug 2026 06:25:10 +0900 Subject: refactor(php-shim): split in_array into strict and loose variants --- crates/shirabe/src/package/alias_package.rs | 11 +++++------ crates/shirabe/src/package/locker.rs | 22 ++++++++++------------ 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'crates/shirabe/src/package') diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs index 8073f3ff..fb775130 100644 --- a/crates/shirabe/src/package/alias_package.rs +++ b/crates/shirabe/src/package/alias_package.rs @@ -11,7 +11,7 @@ use crate::repository::RepositoryInterfaceWeakHandle; use chrono::{DateTime, Utc}; use indexmap::IndexMap; use indexmap::IndexSet; -use shirabe_php_shim::{LogicException, PhpMixed, in_array}; +use shirabe_php_shim::{LogicException, PhpMixed, in_array_strict}; use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug, Clone)] @@ -131,14 +131,13 @@ impl AliasPackage { pretty_version = self.alias_of.get_pretty_version(); } - if in_array( - PhpMixed::String(link_type.to_string()), - &PhpMixed::List(vec![ + if in_array_strict( + link_type.to_string(), + &[ PhpMixed::String(Link::TYPE_CONFLICT.to_string()), PhpMixed::String(Link::TYPE_PROVIDE.to_string()), PhpMixed::String(Link::TYPE_REPLACE.to_string()), - ]), - true, + ], ) { let mut new_links: Vec = vec![]; for link in links.values() { diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index f06f2bdc..10350d78 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -28,8 +28,8 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::seld::json_lint::ParsingException; use shirabe_php_shim::{ DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys, - array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int, - ksort, php_regex, realpath, strcmp, strtolower, touch2, trim, usort, + array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array_loose, + in_array_strict, is_int, ksort, php_regex, realpath, strcmp, strtolower, touch2, trim, usort, }; /// Reads/writes project lockfile (composer.lock). @@ -481,14 +481,13 @@ impl Locker { .and_then(|v| v.as_string()) .unwrap_or("") .to_string(); - if in_array( - PhpMixed::String(version), - &PhpMixed::List(vec![ + if in_array_strict( + version, + &[ PhpMixed::String("dev-master".to_string()), PhpMixed::String("dev-trunk".to_string()), PhpMixed::String("dev-default".to_string()), - ]), - true, + ], ) { alias.insert( "version".to_string(), @@ -807,13 +806,12 @@ impl Locker { let mut datetime: Option> = None; if path.is_some() - && in_array( - PhpMixed::String(source_type.clone().unwrap_or_default()), - &PhpMixed::List(vec![ + && in_array_loose( + source_type.clone().unwrap_or_default(), + &[ PhpMixed::String("git".to_string()), PhpMixed::String("hg".to_string()), - ]), - false, + ], ) { let source_ref = package -- cgit v1.3.1