aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 15:24:55 +0900
committernsfisis <nsfisis@gmail.com>2026-06-26 00:20:05 +0900
commitd4cdccb8de8758bd46a12283f8df90e020327b99 (patch)
treecd7c928cff2615a0bd599cf1f9e09c9852c399d7 /crates/shirabe-php-shim
parent8117e5450693d19726da877bce8aacf5c7aa53af (diff)
downloadphp-shirabe-d4cdccb8de8758bd46a12283f8df90e020327b99.tar.gz
php-shirabe-d4cdccb8de8758bd46a12283f8df90e020327b99.tar.zst
php-shirabe-d4cdccb8de8758bd46a12283f8df90e020327b99.zip
test: port 70 perforce/repository/downloader/installer/dispatcher tests
Port perforce (36), locker (10), composer_repository (7), installation_manager (6), file_downloader (5), and event_dispatcher (6) tests via the mock infra. Fix production porting bugs surfaced en route: BufferIO::get_output look-behind regex, ComposerRepository list-form package iteration and initialize dispatch, gethostname and spl_autoload_functions shims; add EventDispatcher get_listeners test seam. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim')
-rw-r--r--crates/shirabe-php-shim/src/net.rs9
-rw-r--r--crates/shirabe-php-shim/src/runtime.rs7
2 files changed, 13 insertions, 3 deletions
diff --git a/crates/shirabe-php-shim/src/net.rs b/crates/shirabe-php-shim/src/net.rs
index 0ecf5cb..5632c83 100644
--- a/crates/shirabe-php-shim/src/net.rs
+++ b/crates/shirabe-php-shim/src/net.rs
@@ -1,7 +1,14 @@
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
pub fn gethostname() -> String {
- todo!()
+ // PHP's gethostname() wraps gethostname(2). On Linux the kernel exposes the
+ // same value via /proc; fall back to the HOSTNAME env var, then to "localhost".
+ std::fs::read_to_string("/proc/sys/kernel/hostname")
+ .ok()
+ .map(|s| s.trim().to_string())
+ .filter(|s| !s.is_empty())
+ .or_else(|| std::env::var("HOSTNAME").ok().filter(|s| !s.is_empty()))
+ .unwrap_or_else(|| "localhost".to_string())
}
// Resolves the first IPv4 address for the host name, mirroring PHP's gethostbyname
diff --git a/crates/shirabe-php-shim/src/runtime.rs b/crates/shirabe-php-shim/src/runtime.rs
index c1c5f61..73a4189 100644
--- a/crates/shirabe-php-shim/src/runtime.rs
+++ b/crates/shirabe-php-shim/src/runtime.rs
@@ -244,8 +244,11 @@ pub fn error_reporting(level: Option<i64>) -> i64 {
}
pub fn spl_autoload_functions() -> Vec<PhpMixed> {
- // TODO(phase-d): see spl_autoload_register; no autoload registry exists.
- todo!()
+ // In compiled Rust there is no runtime class-autoload registry, so no autoload functions are
+ // ever registered. Callers (e.g. EventDispatcher::do_dispatch, which diffs the registry before
+ // and after running listeners to re-order plugin-prepended autoloaders) therefore always
+ // observe an empty list. See spl_autoload_register/unregister, which remain unimplemented.
+ Vec::new()
}
pub fn version_compare(_v1: &str, _v2: &str, _op: &str) -> bool {