diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 06:19:30 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 06:19:30 +0900 |
| commit | 880a5eaad9dcdfd31563385f11ba1f63d38cfd14 (patch) | |
| tree | 6f9de7b2b8331628a74287112711f65ae3eddc52 /crates/shirabe-class-map-generator | |
| parent | f3d60c7836da0d50d59a22cfd6e4692e3dc75581 (diff) | |
| download | php-shirabe-880a5eaad9dcdfd31563385f11ba1f63d38cfd14.tar.gz php-shirabe-880a5eaad9dcdfd31563385f11ba1f63d38cfd14.tar.zst php-shirabe-880a5eaad9dcdfd31563385f11ba1f63d38cfd14.zip | |
refactor(php-shim): use std::path::MAIN_SEPARATOR over a shim constant
The shim's DIRECTORY_SEPARATOR was hardcoded to "/", so every ported
`'\\' === DIRECTORY_SEPARATOR` check compared against a constant that
does not track the target platform. std::path::MAIN_SEPARATOR and
MAIN_SEPARATOR_STR carry the same meaning as PHP's constant and resolve
per platform, so the Windows branches are selected on Windows targets.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-class-map-generator')
| -rw-r--r-- | crates/shirabe-class-map-generator/src/class_map_generator.rs | 15 |
1 files changed, 7 insertions, 8 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 d1a11c99..30a6ef1e 100644 --- a/crates/shirabe-class-map-generator/src/class_map_generator.rs +++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs @@ -7,10 +7,9 @@ use indexmap::indexmap; 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, - RuntimeException, explode, getcwd, implode, is_dir, is_file, pathinfo, php_regex, preg_quote, - realpath, str_replace, str_starts_with, stream_get_wrappers, strlen, strpos, strrpos, strtr, - substr, + InvalidArgumentException, LogicException, PATHINFO_EXTENSION, PHP_INT_MAX, RuntimeException, + explode, getcwd, implode, 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; @@ -264,10 +263,10 @@ impl ClassMapGenerator { if let Some(ns_len) = namespace_length { let namespace = substr(&class, 0, Some((ns_len + 1) as i64)); let class_name = substr(&class, (ns_len + 1) as i64, None); - sub_path = str_replace("\\", DIRECTORY_SEPARATOR, &namespace) - + &str_replace("_", DIRECTORY_SEPARATOR, &class_name); + sub_path = str_replace("\\", std::path::MAIN_SEPARATOR_STR, &namespace) + + &str_replace("_", std::path::MAIN_SEPARATOR_STR, &class_name); } else { - sub_path = str_replace("_", DIRECTORY_SEPARATOR, &class); + sub_path = str_replace("_", std::path::MAIN_SEPARATOR_STR, &class); } } else if namespace_type == "psr-4" { let sub_namespace = if !base_namespace.is_empty() { @@ -275,7 +274,7 @@ impl ClassMapGenerator { } else { class.clone() }; - sub_path = str_replace("\\", DIRECTORY_SEPARATOR, &sub_namespace); + sub_path = str_replace("\\", std::path::MAIN_SEPARATOR_STR, &sub_namespace); } else { return Err(InvalidArgumentException::new( "$namespaceType must be \"psr-0\" or \"psr-4\"".to_string(), |
