aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/autoload
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 17:29:53 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 17:29:53 +0900
commit277dc4065d2eb0d6621a6aa56a299a0d2369caf7 (patch)
treea93592f8b9e35204ce56a6f325b550c23e87e4ac /crates/shirabe/src/autoload
parent84fe6ac6977f15cbec85cbc9f773567742a7fb87 (diff)
downloadphp-shirabe-277dc4065d2eb0d6621a6aa56a299a0d2369caf7.tar.gz
php-shirabe-277dc4065d2eb0d6621a6aa56a299a0d2369caf7.tar.zst
php-shirabe-277dc4065d2eb0d6621a6aa56a299a0d2369caf7.zip
refactor(autoload): drop dead APCu cache from ClassLoader
apcu_fetch/apcu_add only ran when apcuPrefix was non-null, but Composer never calls setApcuPrefix on the loaders it instantiates itself; the prefix is only emitted into the generated target-project autoload_real.php. So the cache branches were unreachable in Shirabe's execution paths. Remove the apcu shim and the now-dead lookups. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/autoload')
-rw-r--r--crates/shirabe/src/autoload/class_loader.rs33
1 files changed, 8 insertions, 25 deletions
diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs
index b19e618..73b5c06 100644
--- a/crates/shirabe/src/autoload/class_loader.rs
+++ b/crates/shirabe/src/autoload/class_loader.rs
@@ -4,9 +4,9 @@ use indexmap::IndexMap;
use std::sync::{LazyLock, Mutex};
use shirabe_php_shim::{
- DIRECTORY_SEPARATOR, FILTER_VALIDATE_BOOLEAN, InvalidArgumentException, PhpMixed, apcu_add,
- apcu_fetch, array_merge, array_values, call_user_func_array, defined, file_exists, filter_var,
- function_exists, include_file, ini_get, spl_autoload_register, spl_autoload_unregister,
+ DIRECTORY_SEPARATOR, FILTER_VALIDATE_BOOLEAN, InvalidArgumentException, PhpMixed, array_merge,
+ array_values, call_user_func_array, defined, file_exists, filter_var, function_exists,
+ include_file, ini_get, spl_autoload_register, spl_autoload_unregister,
stream_resolve_include_path, strlen, strpos, strrpos, strtr, substr,
};
@@ -273,16 +273,9 @@ impl ClassLoader {
}
/// APCu prefix to use to cache found/not-found classes, if the extension is enabled.
- pub fn set_apcu_prefix(&mut self, apcu_prefix: Option<String>) {
- self.apcu_prefix = if function_exists("apcu_fetch")
- && filter_var(
- &ini_get("apc.enabled").unwrap_or_default(),
- FILTER_VALIDATE_BOOLEAN,
- ) {
- apcu_prefix
- } else {
- None
- };
+ pub fn set_apcu_prefix(&mut self, _apcu_prefix: Option<String>) {
+ // APCu is not available in Rust.
+ self.apcu_prefix = None;
}
/// The APCu prefix in use, or null if APCu caching is not enabled.
@@ -355,11 +348,7 @@ impl ClassLoader {
return None;
}
if let Some(apcu_prefix) = &self.apcu_prefix {
- let mut hit = false;
- let file = apcu_fetch(&format!("{}{}", apcu_prefix, class), &mut hit);
- if hit {
- return file.as_string().map(String::from);
- }
+ // No-op; APCu is not available in Rust.
}
let mut file = self.find_file_with_extension(class, ".php");
@@ -370,13 +359,7 @@ impl ClassLoader {
}
if let Some(apcu_prefix) = &self.apcu_prefix {
- apcu_add(
- &format!("{}{}", apcu_prefix, class),
- match file.as_ref() {
- Some(s) => PhpMixed::String(s.clone()),
- None => PhpMixed::Bool(false),
- },
- );
+ // No-op; APCu is not available in Rust.
}
if file.is_none() {