aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-08 04:30:56 +0900
committernsfisis <nsfisis@gmail.com>2026-06-08 04:30:56 +0900
commit7439cdb08afe0882186a34f70c1e8878fcb7dca5 (patch)
treefdae7e27e2ae107ef97735c0a8fe7d011ba1b3d5
parent632c9793927a30c4bca3c91888e66b369d732dfe (diff)
downloadphp-shirabe-7439cdb08afe0882186a34f70c1e8878fcb7dca5.tar.gz
php-shirabe-7439cdb08afe0882186a34f70c1e8878fcb7dca5.tar.zst
php-shirabe-7439cdb08afe0882186a34f70c1e8878fcb7dca5.zip
feat(phase-c): resolve static-property phase-b TODOs
Implement the FileDownloader::$downloadMetadata accessors over the existing DOWNLOAD_METADATA static, and drop now-stale TODOs on the already-correct Platform::strlen function-local static and the ClassLoader include-closure no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
-rw-r--r--crates/shirabe/src/autoload/class_loader.rs9
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs8
-rw-r--r--crates/shirabe/src/installer/installation_manager.rs1
-rw-r--r--crates/shirabe/src/util/platform.rs1
4 files changed, 9 insertions, 10 deletions
diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs
index 745e9f2..083e1c3 100644
--- a/crates/shirabe/src/autoload/class_loader.rs
+++ b/crates/shirabe/src/autoload/class_loader.rs
@@ -17,7 +17,9 @@ static REGISTERED_LOADERS: LazyLock<Mutex<IndexMap<String, ClassLoader>>> =
/// ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
#[derive(Debug, Clone)]
pub struct ClassLoader {
- // PHP: private static $includeFile — TODO(phase-b): stash include closure as a static
+ // PHP holds a `private static $includeFile` closure purely to run `include $file` in an
+ // isolated scope. The `include_file` shim is a free function with no `self`/`Self` access, so
+ // that scope isolation is inherent and there is no static state to keep on the Rust side.
/// @var string|null
vendor_dir: Option<String>,
@@ -491,8 +493,9 @@ impl ClassLoader {
}
fn initialize_include_closure() {
- // TODO(phase-b): preserve PHP `\Closure::bind(static fn($file) => include $file, null, null)`
- // Rust has no `include` operator; this is a no-op placeholder.
+ // PHP lazily binds `self::$includeFile` to a scope-isolated `include $file` closure. The
+ // Rust `include_file` shim already provides that isolation as a free function, so there is
+ // no closure to bind and this is intentionally a no-op.
}
/// PHP `(array) $loader`. Every property is private, so keys are mangled as
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index 9840cef..54b0882 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -82,14 +82,12 @@ pub struct FileDownloader {
}
impl FileDownloader {
- /// TODO(phase-b): `$downloadMetadata` is a static property in PHP; not yet mapped to Rust.
pub fn reset_download_metadata() {
- todo!("FileDownloader::reset_download_metadata")
+ DOWNLOAD_METADATA.lock().unwrap().clear();
}
- /// TODO(phase-b): `$downloadMetadata` is a static property in PHP; not yet mapped to Rust.
- pub fn download_metadata() -> indexmap::IndexMap<String, shirabe_php_shim::PhpMixed> {
- todo!("FileDownloader::download_metadata")
+ pub fn download_metadata() -> IndexMap<String, PhpMixed> {
+ DOWNLOAD_METADATA.lock().unwrap().clone()
}
/// Constructor.
diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs
index 6f691c6..17d284d 100644
--- a/crates/shirabe/src/installer/installation_manager.rs
+++ b/crates/shirabe/src/installer/installation_manager.rs
@@ -64,7 +64,6 @@ impl InstallationManager {
pub fn reset(&mut self) {
self.notifiable_packages = IndexMap::new();
- // TODO(phase-b): FileDownloader::$downloadMetadata is a static property
FileDownloader::reset_download_metadata();
}
diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs
index bb5ce1b..3866a12 100644
--- a/crates/shirabe/src/util/platform.rs
+++ b/crates/shirabe/src/util/platform.rs
@@ -270,7 +270,6 @@ impl Platform {
/// @return int return a guaranteed binary length of the string, regardless of silly mbstring configs
pub fn strlen(str: &str) -> i64 {
- // TODO(phase-b): function-local static; collapse to a Mutex<Option<bool>> in Phase B
static USE_MB_STRING: Mutex<Option<bool>> = Mutex::new(None);
let mut use_mb_string = USE_MB_STRING.lock().unwrap();
if use_mb_string.is_none() {