From 2d474e91e49c7343d28198eff2b5bbbed9afbcee Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 10 Jun 2026 02:41:34 +0900 Subject: feat(phase-c): resolve cross-module phase-b TODOs --- crates/shirabe/src/util/http_downloader.rs | 3 ++- crates/shirabe/src/util/platform.rs | 22 ++-------------------- crates/shirabe/src/util/remote_filesystem.rs | 6 ++++-- 3 files changed, 8 insertions(+), 23 deletions(-) (limited to 'crates/shirabe/src/util') diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index 5d0eae6..434dedb 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -779,7 +779,8 @@ impl HttpDownloader { ); http_map.insert("ignore_errors".to_string(), Box::new(PhpMixed::Bool(true))); ctx_options.insert("http".to_string(), PhpMixed::Array(http_map)); - // TODO(phase-b): file_get_contents only takes a path; stream context arg dropped. + // TODO(phase-c): file_get_contents only takes a path; the stream context arg is dropped + // until the PHP stream-context layer is modeled. let _ = stream_context_create(&ctx_options, None); let test_connectivity = file_get_contents("https://8.8.8.8"); Silencer::restore(); diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 3866a12..6a0c2d0 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -186,7 +186,6 @@ impl Platform { return false; } - // TODO(phase-b): Silencer::call returns Result; PHP returns the value or false on error let file_contents = Silencer::call(|| Ok(file_get_contents("/proc/version"))) .ok() .flatten() @@ -294,7 +293,8 @@ impl Platform { Some(f) => f, None => { if defined("STDOUT") { - // TODO(phase-b): map STDOUT to the runtime stdout resource + // TODO(phase-c): map the STDOUT constant to a runtime stdout resource; depends + // on the unmodeled PHP stream/resource layer. todo!("STDOUT constant") } else { let fd = fopen("php://stdout", "w"); @@ -330,7 +330,6 @@ impl Platform { return true; } - // TODO(phase-b): Silencer::call wraps the fstat call (`@fstat($fd)`) let stat = Silencer::call(|| Ok(fstat(fd))); let stat = match stat { Ok(s) => s, @@ -427,25 +426,8 @@ impl Platform { "/dev/null".to_string() } - /// PHP: PHP_OS — returns the OS PHP was built on. - pub fn php_os() -> &'static str { - // TODO(phase-b): map to actual OS name (e.g. "Darwin", "Linux", "WINNT"). - todo!() - } - /// PHP: rename($from, $to) — wrap the std rename so callers can use Platform::rename. pub fn rename(from: &str, to: &str) -> bool { std::fs::rename(from, to).is_ok() } - - /// PHP: mkdir($pathname, $mode, $recursive) - pub fn mkdir(pathname: &str, _mode: u32, recursive: bool) -> bool { - // TODO(phase-b): honor mode bits on Unix - let result = if recursive { - std::fs::create_dir_all(pathname) - } else { - std::fs::create_dir(pathname) - }; - result.is_ok() - } } diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index bd4aaa8..dc6a2a4 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -720,7 +720,8 @@ impl RemoteFilesystem { } let mut caught_e: Option = None; - // TODO(phase-b): wrap PHP's `file_get_contents` with stream context and error capture. + // TODO(phase-c): wrap PHP's `file_get_contents` with stream context and error capture; + // depends on the unmodeled PHP stream-context layer. let outer: Result, anyhow::Error> = Ok(None); match outer { Ok(v) => result = v, @@ -743,7 +744,8 @@ impl RemoteFilesystem { *response_headers = http_get_last_response_headers().unwrap_or_default(); http_clear_last_response_headers(); } else { - // TODO(phase-b): read the magic `$http_response_header` PHP variable. + // TODO(phase-c): read the magic `$http_response_header` PHP variable; depends on the + // unmodeled PHP stream layer that populates it. *response_headers = Vec::new(); } -- cgit v1.3.1