aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/autoload
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-14 11:24:36 +0900
committernsfisis <nsfisis@gmail.com>2026-06-14 11:28:19 +0900
commit716f44031a39c5e43fb441ecc470db76efc23dd4 (patch)
treee6f4a31e4bf55a0a8efb06d9dd4844c567e7390f /crates/shirabe/src/autoload
parentef9118c788c1cbb22ca7721b6a9e40c2bf2fe243 (diff)
downloadphp-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.tar.gz
php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.tar.zst
php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.zip
refactor(pcre): drop Result from Preg method return types
The Preg methods panic on PCRE failure (per the file header rationale), so their anyhow::Result wrappers never carried an Err. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/autoload')
-rw-r--r--crates/shirabe/src/autoload/autoload_generator.rs30
1 files changed, 9 insertions, 21 deletions
diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs
index e8883ab..6ceb02c 100644
--- a/crates/shirabe/src/autoload/autoload_generator.rs
+++ b/crates/shirabe/src/autoload/autoload_generator.rs
@@ -517,9 +517,7 @@ impl AutoloadGenerator {
"{ComposerAutoloaderInit([^:\\s]+)::}",
&content,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
suffix = matches.get(&CaptureKey::ByIndex(1)).cloned();
}
}
@@ -702,8 +700,7 @@ impl AutoloadGenerator {
"{^(([^.+*?\\[^\\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\\[^\\]$(){}=!<>|:#-])*).*}",
"$1",
pattern,
- )
- .unwrap_or_default();
+ );
// if the pattern is not a subset or superset of $dir, it is unrelated and we skip it
let unrelated = (!str_starts_with(&pattern_processed, &dir_match)
&& !str_starts_with(&dir_match, &pattern_processed))
@@ -1069,7 +1066,7 @@ impl AutoloadGenerator {
}
}
- if Preg::is_match("{\\.phar([\\\\/]|$)}", &path).unwrap_or(false) {
+ if Preg::is_match("{\\.phar([\\\\/]|$)}", &path) {
base_dir = format!("'phar://' . {}", base_dir);
}
@@ -1095,9 +1092,7 @@ impl AutoloadGenerator {
let links = array_merge_map(package.get_replaces(), package.get_provides());
for (_k, link) in &links {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match3("{^ext-(.+)$}iD", link.get_target(), Some(&mut matches))
- .unwrap_or(false)
- {
+ if Preg::match3("{^ext-(.+)$}iD", link.get_target(), Some(&mut matches)) {
if let Some(ext) = matches.get(&CaptureKey::ByIndex(1)).cloned() {
extension_providers
.entry(ext)
@@ -1141,7 +1136,6 @@ impl AutoloadGenerator {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
if check_platform.as_bool() == Some(true)
&& Preg::match3("{^ext-(.+)$}iD", link.get_target(), Some(&mut matches))
- .unwrap_or(false)
{
let ext_key = matches
.get(&CaptureKey::ByIndex(1))
@@ -1591,11 +1585,8 @@ impl AutoloadGenerator {
);
m
});
- let value = shirabe_php_shim::ltrim(
- &Preg::replace("/^ */m", " $0$0", &value).unwrap_or_default(),
- None,
- );
- let value = Preg::replace("/ +$/m", "", &value).unwrap_or_default();
+ let value = shirabe_php_shim::ltrim(&Preg::replace("/^ */m", " $0$0", &value), None);
+ let value = Preg::replace("/ +$/m", "", &value);
file.push_str(&format!(
" public static ${} = {};\n\n",
@@ -1712,8 +1703,7 @@ impl AutoloadGenerator {
&format!("{{^{}}}", target_dir),
"",
&ltrim(&path_str, Some("\\/")),
- )
- .unwrap_or_default(),
+ ),
Some("\\/"),
);
} else {
@@ -1732,8 +1722,7 @@ impl AutoloadGenerator {
"{/+}",
"/",
&preg_quote(&trim(&strtr(&path_str, "\\", "/"), Some("/")), None),
- )
- .unwrap_or_default();
+ );
// add support for wildcards * and **
let p = shirabe_php_shim::strtr_array(&p, &{
@@ -1762,8 +1751,7 @@ impl AutoloadGenerator {
String::new()
},
&p,
- )
- .unwrap_or_default();
+ );
let updir: Option<String> = updir_cell.into_inner();
let install_path_for_resolve = if install_path.is_empty() {
strtr(&Platform::get_cwd(false).unwrap_or_default(), "\\", "/")