aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-class-map-generator/src/class_map_generator.rs17
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/executable_finder.rs26
-rw-r--r--crates/shirabe-php-shim/src/fs.rs8
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs18
-rw-r--r--crates/shirabe/src/downloader/gzip_downloader.rs11
-rw-r--r--crates/shirabe/src/factory.rs11
6 files changed, 29 insertions, 62 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 9fa37246..0f98ca27 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_strict, is_dir, is_file,
- pathinfo, php_regex, preg_quote, realpath, str_replace, str_starts_with, stream_get_wrappers,
- strlen, strpos, strrpos, strtr, substr,
+ 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;
@@ -137,15 +137,8 @@ impl ClassMapGenerator {
}));
}
};
- let ext = pathinfo(PhpMixed::String(file_path.clone()), PATHINFO_EXTENSION);
- if !in_array_strict(
- ext,
- &self
- .extensions
- .iter()
- .map(|e| PhpMixed::String(e.clone()))
- .collect::<Vec<_>>(),
- ) {
+ let ext = pathinfo(&file_path, PATHINFO_EXTENSION);
+ if !self.extensions.contains(&ext) {
continue;
}
diff --git a/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs b/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs
index d4891af0..3c44b4ad 100644
--- a/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs
@@ -1,7 +1,5 @@
//! ref: composer/vendor/symfony/process/ExecutableFinder.php
-use shirabe_php_shim::PhpMixed;
-
const CMD_BUILTINS: &[&str] = &[
"assoc", "break", "call", "cd", "chdir", "cls", "color", "copy", "date", "del", "dir", "echo",
"endlocal", "erase", "exit", "for", "ftype", "goto", "help", "if", "label", "md", "mkdir",
@@ -58,21 +56,15 @@ impl ExecutableFinder {
};
suffixes.extend(exts);
}
- suffixes = if !shirabe_php_shim::pathinfo(
- PhpMixed::String(name.to_string()),
- shirabe_php_shim::PATHINFO_EXTENSION,
- )
- .as_string()
- .unwrap_or("")
- .is_empty()
- {
- let mut s = vec![String::new()];
- s.extend(suffixes);
- s
- } else {
- suffixes.push(String::new());
- suffixes
- };
+ suffixes =
+ if !shirabe_php_shim::pathinfo(name, shirabe_php_shim::PATHINFO_EXTENSION).is_empty() {
+ let mut s = vec![String::new()];
+ s.extend(suffixes);
+ s
+ } else {
+ suffixes.push(String::new());
+ suffixes
+ };
for suffix in &suffixes {
for dir in &dirs {
let dir = if dir.is_empty() { "." } else { dir.as_str() };
diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs
index ac7a4f99..c3f131b3 100644
--- a/crates/shirabe-php-shim/src/fs.rs
+++ b/crates/shirabe-php-shim/src/fs.rs
@@ -1075,9 +1075,8 @@ pub fn opendir(path: impl AsRef<std::path::Path>) -> Option<PhpDirHandle> {
})
}
-pub fn pathinfo(path: PhpMixed, option: i64) -> PhpMixed {
- let path = path.as_string().unwrap_or("");
- let component = match option {
+pub fn pathinfo(path: &str, option: i64) -> String {
+ match option {
PATHINFO_DIRNAME => dirname(path),
PATHINFO_BASENAME => basename(path),
PATHINFO_EXTENSION => {
@@ -1095,8 +1094,7 @@ pub fn pathinfo(path: PhpMixed, option: i64) -> PhpMixed {
}
}
_ => unreachable!("pathinfo called with an unsupported single-component option"),
- };
- PhpMixed::String(component)
+ }
}
// TODO(phase-c): returns Option<PathBuf>
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index c5dfc5f7..4ee580f8 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -712,20 +712,14 @@ impl FileDownloader {
impl FileDownloader {
fn get_dist_path(&self, package: PackageInterfaceHandle, component: i64) -> String {
pathinfo(
- PhpMixed::String(
- parse_url(
- &strtr(&package.get_dist_url().unwrap_or_default(), "\\", "/"),
- PHP_URL_PATH,
- )
- .as_string()
- .unwrap_or("")
- .to_string(),
- ),
+ parse_url(
+ &strtr(&package.get_dist_url().unwrap_or_default(), "\\", "/"),
+ PHP_URL_PATH,
+ )
+ .as_string()
+ .unwrap_or(""),
component,
)
- .as_string()
- .unwrap_or("")
- .to_string()
}
pub(crate) fn clear_last_cache_write(&self, package: PackageInterfaceHandle) {
diff --git a/crates/shirabe/src/downloader/gzip_downloader.rs b/crates/shirabe/src/downloader/gzip_downloader.rs
index 70b9f7bb..297cbc11 100644
--- a/crates/shirabe/src/downloader/gzip_downloader.rs
+++ b/crates/shirabe/src/downloader/gzip_downloader.rs
@@ -84,15 +84,12 @@ impl ArchiveDownloader for GzipDownloader {
parse_url(
&strtr(&package.get_dist_url().unwrap_or_default(), "\\", "/"),
PHP_URL_PATH,
- ),
+ )
+ .as_string()
+ .unwrap_or(""),
PATHINFO_FILENAME,
);
- let target_filepath = format!(
- "{}{}{}",
- path,
- DIRECTORY_SEPARATOR,
- filename.as_string().unwrap_or_default()
- );
+ let target_filepath = format!("{}{}{}", path, DIRECTORY_SEPARATOR, filename);
if !Platform::is_windows() {
let command = vec![
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs
index de632143..7328bf42 100644
--- a/crates/shirabe/src/factory.rs
+++ b/crates/shirabe/src/factory.rs
@@ -375,15 +375,8 @@ impl Factory {
}
pub fn get_lock_file(composer_file: &str) -> String {
- let ext = pathinfo(
- PhpMixed::String(composer_file.to_string()),
- PATHINFO_EXTENSION,
- );
- let is_json = match ext {
- PhpMixed::String(s) => s == "json",
- _ => false,
- };
- if is_json {
+ let ext = pathinfo(composer_file, PATHINFO_EXTENSION);
+ if ext == "json" {
format!(
"{}lock",
substr(composer_file, 0, Some(composer_file.len() as i64 - 4))