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/locker.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'crates/shirabe/src/package/locker.rs') 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