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-class-map-generator/src/class_map_generator.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-class-map-generator/src/class_map_generator.rs')
| -rw-r--r-- | crates/shirabe-class-map-generator/src/class_map_generator.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs index 2f851298..57a21508 100644 --- a/crates/shirabe-class-map-generator/src/class_map_generator.rs +++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs @@ -8,9 +8,9 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::symfony::finder::Finder; use shirabe_php_shim::{ DIRECTORY_SEPARATOR, InvalidArgumentException, LogicException, PATHINFO_EXTENSION, PHP_INT_MAX, - PhpMixed, RuntimeException, explode, getcwd, implode, in_array, is_dir, is_file, pathinfo, - php_regex, preg_quote, realpath, str_replace, str_starts_with, stream_get_wrappers, strlen, - strpos, strrpos, strtr, substr, + PhpMixed, RuntimeException, explode, getcwd, implode, in_array_strict, is_dir, is_file, + pathinfo, php_regex, preg_quote, realpath, str_replace, str_starts_with, stream_get_wrappers, + strlen, strpos, strrpos, strtr, substr, }; use std::path::PathBuf; @@ -73,14 +73,13 @@ impl ClassMapGenerator { namespace: Option<String>, excluded_dirs: Vec<String>, ) -> anyhow::Result<()> { - if !in_array( - PhpMixed::String(autoload_type.to_string()), - &PhpMixed::List(vec![ + if !in_array_strict( + autoload_type.to_string(), + &[ PhpMixed::String("psr-0".to_string()), PhpMixed::String("psr-4".to_string()), PhpMixed::String("classmap".to_string()), - ]), - true, + ], ) { return Err(anyhow::anyhow!(InvalidArgumentException { message: "$autoloadType must be one of: \"psr-0\", \"psr-4\" or \"classmap\"" @@ -146,15 +145,13 @@ impl ClassMapGenerator { } }; let ext = pathinfo(PhpMixed::String(file_path.clone()), PATHINFO_EXTENSION); - if !in_array( + if !in_array_strict( ext, - &PhpMixed::List( - self.extensions - .iter() - .map(|e| PhpMixed::String(e.clone())) - .collect(), - ), - true, + &self + .extensions + .iter() + .map(|e| PhpMixed::String(e.clone())) + .collect::<Vec<_>>(), ) { continue; } |
