From 7439cdb08afe0882186a34f70c1e8878fcb7dca5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 8 Jun 2026 04:30:56 +0900 Subject: 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) --- crates/shirabe/src/autoload/class_loader.rs | 9 ++++++--- crates/shirabe/src/downloader/file_downloader.rs | 8 +++----- crates/shirabe/src/installer/installation_manager.rs | 1 - crates/shirabe/src/util/platform.rs | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'crates') 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>> = /// 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, @@ -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 { - todo!("FileDownloader::download_metadata") + pub fn download_metadata() -> IndexMap { + 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> in Phase B static USE_MB_STRING: Mutex> = Mutex::new(None); let mut use_mb_string = USE_MB_STRING.lock().unwrap(); if use_mb_string.is_none() { -- cgit v1.3.1