From b291e714bc739262140323e08fe2fb9e91e00ee7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 22 Jun 2026 23:41:12 +0900 Subject: feat(php-shim): implement fopen-family stream API on PhpResource Redesign PhpResource into a real stream handle (File/Memory backing with tracked position, eof, closed state) and unify the whole fopen family (fopen/fwrite/fread/fgets/fgetc/feof/fclose/ftell/fseek/rewind/fstat/ ftruncate/fflush and stream_get_contents/stream_copy_to_stream) on &PhpResource, replacing the split PhpMixed/PhpResource APIs and their todo!() stubs. fopen now returns Result; read functions stay String for now (TODO(phase-e) to move to byte strings). Propagate the signatures through callers: Process stdout/stderr, Cursor input, curl header/body handles (extracted into typed maps keyed by job id), Filesystem copy/safe_copy/files_are_equal, BufferIO, error_handler, platform, perforce, zip. The proc_open pipe paths cannot carry a PhpResource in a PhpMixed list, so they are left as todo!() with notes. --- .../src/symfony/process/pipes/abstract_pipes.rs | 9 ++------- .../src/symfony/process/pipes/unix_pipes.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/process/pipes') diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs index 47db6b9..d8ced43 100644 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs +++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs @@ -37,13 +37,8 @@ impl AbstractPipes { } pub fn close(&mut self) { - if let PhpMixed::List(pipes) = &self.pipes { - for pipe in pipes { - if php::is_resource(pipe) { - php::fclose(pipe.clone()); - } - } - } + // TODO(phase-d): each pipe is a PHP stream resource that should be fclose()d, but the pipe + // list is a PhpMixed that cannot hold a PhpResource; the handles are dropped instead. self.pipes = PhpMixed::List(Vec::new()); } diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs index 387bcdf..983ed07 100644 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs +++ b/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs @@ -44,9 +44,12 @@ fn descriptor(items: &[&str]) -> PhpMixed { impl PipesInterface for UnixPipes { fn get_descriptors(&mut self) -> Vec { if !self.have_read_support { - let nullstream = shirabe_php_shim::fopen("/dev/null", "c"); - - return vec![descriptor(&["pipe", "r"]), nullstream.clone(), nullstream]; + // TODO(phase-d): /dev/null is opened as a stream resource and placed directly into the + // proc_open descriptor spec, but the descriptor list is a Vec that cannot + // carry a PhpResource. + todo!( + "UnixPipes::get_descriptors: the /dev/null resource cannot be represented in a PhpMixed descriptor list" + ); } if self.tty_mode == Some(true) { -- cgit v1.3.1