aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-php-shim/src')
-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 {