diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-06 06:25:10 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-06 06:25:30 +0900 |
| commit | 791ef1cd465597ff43dab4216c4b00e9e4160da8 (patch) | |
| tree | ec6c3bc45f81576146325350faa6dcea638987b4 /crates/shirabe/src/downloader | |
| parent | a86bbd67954f7bbc38bb09138edb335d82666526 (diff) | |
| download | php-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/downloader')
| -rw-r--r-- | crates/shirabe/src/downloader/download_manager.rs | 17 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/file_downloader.rs | 13 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/git_downloader.rs | 6 |
3 files changed, 16 insertions, 20 deletions
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index ea3fed41..7ff21a25 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -11,7 +11,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_keys, - array_reverse, array_shift, dirname, implode, in_array, preg_quote, rtrim, str_replace, + array_reverse, array_shift, dirname, implode, in_array_strict, preg_quote, rtrim, str_replace, strtolower, usort, }; @@ -487,15 +487,12 @@ impl DownloadManager { if let Some(prev) = prev_package { // if we are updating, we want to keep the same source as the previously installed package (if available in the new one) let prev_source = prev.get_installation_source(); - if in_array( - PhpMixed::String(prev_source.clone().unwrap_or_default()), - &PhpMixed::List( - sources - .iter() - .map(|s| PhpMixed::String(s.clone())) - .collect(), - ), - true, + if in_array_strict( + prev_source.clone().unwrap_or_default(), + &sources + .iter() + .map(|s| PhpMixed::String(s.clone())) + .collect::<Vec<_>>(), ) // unless the previous package was stable dist (by default) and the new package is dev, then we allow the new default to take over && !(!prev.is_dev() diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index 48925b4b..c6ee3a20 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -28,8 +28,8 @@ use indexmap::IndexMap; use shirabe_php_shim::{ DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists, - filesize, get_class, hash, hash_file, in_array, is_dir, is_executable, parse_url, pathinfo, - realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep, + filesize, get_class, hash, hash_file, in_array_strict, is_dir, is_executable, parse_url, + pathinfo, realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep, }; use std::sync::{LazyLock, Mutex}; @@ -339,15 +339,14 @@ impl DownloaderInterface for FileDownloader { if let Some(te) = e.downcast_ref::<TransportException>() { // if we got an http response with a proper code, then requesting again will probably not help, abort if 0 != te.get_code() - && !in_array( - PhpMixed::Int(te.get_code()), - &PhpMixed::List(vec![ + && !in_array_strict( + te.get_code(), + &[ PhpMixed::Int(500), PhpMixed::Int(502), PhpMixed::Int(503), PhpMixed::Int(504), - ]), - true, + ], ) { retries = 0; diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index e9c70da3..0becf427 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -19,8 +19,8 @@ use crate::util::Url; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array, is_dir, php_regex, - preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare, + PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array_strict, is_dir, + php_regex, preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare, }; #[derive(Debug)] @@ -537,7 +537,7 @@ impl GitDownloader { .cloned() .unwrap_or_default(); let mut push_url = format!("git@{}:{}/{}.git", m1, m2, m3); - if !in_array(PhpMixed::String("ssh".to_string()), &protocols, true) { + if !in_array_strict("ssh".to_string(), protocols.values()) { push_url = format!("https://{}/{}/{}.git", m1, m2, m3); } let cmd = vec