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/io/base_io.rs | |
| 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/io/base_io.rs')
| -rw-r--r-- | crates/shirabe/src/io/base_io.rs | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/crates/shirabe/src/io/base_io.rs b/crates/shirabe/src/io/base_io.rs index 126c1201..5dd7682f 100644 --- a/crates/shirabe/src/io/base_io.rs +++ b/crates/shirabe/src/io/base_io.rs @@ -10,7 +10,8 @@ use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::psr::log::LogLevel; use shirabe_php_shim::{ JSON_INVALID_UTF8_IGNORE, JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE, PhpMixed, - UnexpectedValueException, array_merge, in_array, json_encode_ex, php_regex, + UnexpectedValueException, array_merge, in_array_loose, in_array_strict, json_encode_ex, + php_regex, }; fn log_context(context: &[(&str, &str)]) -> IndexMap<String, PhpMixed> { @@ -116,10 +117,12 @@ pub trait BaseIO: IOInterface { let token_str = token.as_string().unwrap_or("").to_string(); let github_domains = config.get("github-domains"); if domain != "github.com" - && !in_array( - PhpMixed::String(domain.clone()), - &github_domains.clone().unwrap_or(PhpMixed::List(vec![])), - true, + && !in_array_strict( + domain.clone(), + github_domains + .clone() + .unwrap_or(PhpMixed::List(vec![])) + .values(), ) { <Self as BaseIO>::debug( @@ -162,10 +165,12 @@ pub trait BaseIO: IOInterface { for (domain, token) in map.clone() { let gitlab_domains = config.get("gitlab-domains"); if domain != "gitlab.com" - && !in_array( - PhpMixed::String(domain.clone()), - &gitlab_domains.clone().unwrap_or(PhpMixed::List(vec![])), - true, + && !in_array_strict( + domain.clone(), + gitlab_domains + .clone() + .unwrap_or(PhpMixed::List(vec![])) + .values(), ) { <Self as BaseIO>::debug( @@ -203,10 +208,12 @@ pub trait BaseIO: IOInterface { for (domain, token) in map.clone() { let gitlab_domains = config.get("gitlab-domains"); if domain != "gitlab.com" - && !in_array( - PhpMixed::String(domain.clone()), - &gitlab_domains.clone().unwrap_or(PhpMixed::List(vec![])), - true, + && !in_array_strict( + domain.clone(), + gitlab_domains + .clone() + .unwrap_or(PhpMixed::List(vec![])) + .values(), ) { <Self as BaseIO>::debug( @@ -252,10 +259,12 @@ pub trait BaseIO: IOInterface { if let Some(map) = forgejo_token.as_opt().and_then(|v| v.as_array()) { for (domain, cred) in map.clone() { let forgejo_domains = config.get("forgejo-domains"); - if !in_array( - PhpMixed::String(domain.clone()), - &forgejo_domains.clone().unwrap_or(PhpMixed::List(vec![])), - true, + if !in_array_strict( + domain.clone(), + forgejo_domains + .clone() + .unwrap_or(PhpMixed::List(vec![])) + .values(), ) { <Self as BaseIO>::debug( self, @@ -461,15 +470,14 @@ pub trait BaseIO: IOInterface { } let level_str = level.as_string().unwrap_or(""); - if in_array( + if in_array_loose( level.clone(), - &PhpMixed::List(vec![ + &[ PhpMixed::String(LogLevel::EMERGENCY.to_string()), PhpMixed::String(LogLevel::ALERT.to_string()), PhpMixed::String(LogLevel::CRITICAL.to_string()), PhpMixed::String(LogLevel::ERROR.to_string()), - ]), - false, + ], ) { self.write_error3( &format!("<error>{}</error>", message_str), |
