From f1edda70e5eba2f7db36ea17bc7a4588bcd8d2fc Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 15 Aug 2026 14:24:54 +0900 Subject: docs(php-shim): state the ignored file I/O flags as a contract The two TODOs marked deferred work that nothing reaches. FILE_USE_INCLUDE_PATH appears nowhere in Composer or its vendored dependencies, and the only site passing LOCK_EX to file_put_contents is Symfony's Filesystem::appendToFile(), which no caller invokes and which raises the flag only when handed a third argument. The stream $context is dropped just as narrowly: the network scheme that would carry one is already marked at the call site in RemoteFilesystem, leaving the shim reachable through the local-file branch alone. Record what these functions do and do not support instead, so the tags stay a list of work that is actually pending. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-shim/src/fs.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index 7bf36cde..296f8f4a 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -878,9 +878,8 @@ pub fn file_put_contents(path: &str, data: &[u8]) -> Option { std::fs::write(path, data).ok().map(|_| data.len() as i64) } +/// Only `FILE_APPEND` is honored; `LOCK_EX` and `FILE_USE_INCLUDE_PATH` have no effect. pub fn file_put_contents3(filename: &str, data: &str, flags: i64) -> Option { - // TODO(php-semantics): the LOCK_EX and FILE_USE_INCLUDE_PATH flags are ignored; only FILE_APPEND is - // honored. let append = flags & FILE_APPEND != 0; let mut opts = std::fs::OpenOptions::new(); opts.write(true).create(true); @@ -906,6 +905,8 @@ pub fn file_get_contents(path: impl AsRef) -> Option { .map(|bytes| String::from_utf8_lossy(&bytes).into_owned()) } +/// `$use_include_path` and the stream `$context` have no effect; the read always goes to the +/// local filesystem. pub fn file_get_contents5( path: &str, _use_include_path: bool, @@ -913,8 +914,6 @@ pub fn file_get_contents5( offset: i64, length: Option, ) -> Option { - // TODO(php-semantics): the stream $context and FILE_USE_INCLUDE_PATH are ignored; only $offset and - // $length are applied (to the file read from the local filesystem). // PHP supports the file:// stream wrapper; strip it to read the local file. let path = path.strip_prefix("file://").unwrap_or(path); let bytes = std::fs::read(path).ok()?; -- cgit v1.3.1-4-g156e