From 84655bf3a4a21dbbe7aec8e3aee1e661505bbb6d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 20 Jun 2026 23:37:42 +0900 Subject: feat(symfony-process): port full Process class from PHP Faithfully port every method, field and constant of Symfony's Process.php into process.rs, replacing the reduced stub. Add the supporting pipes module (PipesInterface/AbstractPipes/UnixPipes/ WindowsPipes), ProcessUtils and the missing process exceptions (LogicException/InvalidArgumentException) with constructors. Methods now return anyhow::Result where PHP throws, take the env argument and a bool-returning callback, and borrow &mut for status-updating accessors; all callers are updated accordingly. Extend the php-shim with proc_open/proc_close (PHP-compatible signatures), proc_get_status, proc_terminate, posix_kill, uniqid, ftruncate, ftell_stream, fseek3, stream_get_contents3 and env helpers. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe-php-shim/src/lib.rs | 63 +++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'crates/shirabe-php-shim') diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index 4bb309e..b85d9f2 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -3467,16 +3467,63 @@ pub fn stdin() -> PhpResource { PhpResource::Stdin } -// TODO(phase-c): reports proc_open as unavailable, so callers (terminal size and -// tty detection) fall back to their defaults. A real implementation requires a -// non-lossy signature able to hold the child process and its pipes; defer it to -// the broader process-subsystem work (ProcessExecutor). -pub fn proc_open(_command: &str, _descriptorspec: &Vec, _pipes: &mut PhpMixed) -> bool { - false -} -pub fn proc_close(_process: bool) -> i64 { +// TODO(phase-c): reports proc_open as unavailable (returns false), so callers fall back to +// their defaults. A real implementation requires holding the child process and its pipes; defer +// it to the broader process-subsystem work (ProcessExecutor). +pub fn proc_open( + _command: &str, + _descriptorspec: &[PhpMixed], + _pipes: &mut PhpMixed, + _cwd: Option<&str>, + _env: Option<&[String]>, + _options: Option<&IndexMap>, +) -> PhpMixed { + PhpMixed::Bool(false) +} +pub fn proc_close(_process: PhpMixed) -> i64 { -1 } +pub fn proc_get_status(_process: &PhpMixed) -> IndexMap { + todo!() +} +pub fn proc_terminate(_process: &PhpMixed, _signal: i64) -> bool { + todo!() +} +pub fn posix_kill(_pid: i64, _signal: i64) -> bool { + todo!() +} +pub fn uniqid(_prefix: &str, _more_entropy: bool) -> String { + todo!() +} +pub fn ftruncate(_stream: &PhpMixed, _size: i64) -> bool { + todo!() +} +/// PHP `ftell()` over a PhpMixed stream resource. (`ftell` itself is already defined for the +/// `PhpResource`-typed stream API used elsewhere.) +pub fn ftell_stream(_stream: &PhpMixed) -> i64 { + todo!() +} +pub const SEEK_SET: i64 = 0; +pub const SEEK_CUR: i64 = 1; +pub const SEEK_END: i64 = 2; +pub fn fseek3(_stream: PhpMixed, _offset: i64, _whence: i64) -> i64 { + todo!() +} +pub fn stream_get_contents3(_stream: PhpMixed, _max_length: i64, _offset: i64) -> Option { + todo!() +} +/// PHP `getenv()` with no argument: all environment variables. +pub fn getenv_all() -> IndexMap { + todo!() +} +/// PHP superglobal `$_ENV`. +pub fn php_env() -> IndexMap { + todo!() +} +/// PHP superglobal `$_SERVER`. +pub fn php_server() -> IndexMap { + todo!() +} pub fn sapi_windows_vt100_support(_resource: &PhpResource) -> bool { todo!() -- cgit v1.3.1