aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/platform/runtime.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-04 03:19:52 +0900
committernsfisis <nsfisis@gmail.com>2026-07-04 15:28:38 +0900
commit425eeea92e00ecbfccfc0b13dbc1cfb41d09069c (patch)
treef515497c8db83e2aa42d6cc61a6fdd7014035426 /crates/shirabe/src/platform/runtime.rs
parent1fdbfc1a277a788f8317ed47fccda22c587d3363 (diff)
downloadphp-shirabe-425eeea92e00ecbfccfc0b13dbc1cfb41d09069c.tar.gz
php-shirabe-425eeea92e00ecbfccfc0b13dbc1cfb41d09069c.tar.zst
php-shirabe-425eeea92e00ecbfccfc0b13dbc1cfb41d09069c.zip
fix(php-rpc): wire Runtime::invoke/get_extension_info/extensions
Route the platform-repository seams that need real PHP introspection through php-rpc instead of todo!()/hardcoded shims: - Runtime::invoke now handles the two dynamic callables PlatformRepository actually reaches (inet_pton, curl_version) via new php-rpc calls; other callables remain unsupported. - Runtime::get_extension_info uses a new `extension_info` php-rpc call (ReflectionExtension::info() + output buffering) instead of todo!(). - Runtime::get_extensions/get_extension_version now query the real PHP process (get_loaded_extensions, phpversion) instead of the shirabe-php-shim's hardcoded "standard CLI environment" model, so platform requirement checks see the extensions actually installed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/platform/runtime.rs')
-rw-r--r--crates/shirabe/src/platform/runtime.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/crates/shirabe/src/platform/runtime.rs b/crates/shirabe/src/platform/runtime.rs
index e4ff64a..4029790 100644
--- a/crates/shirabe/src/platform/runtime.rs
+++ b/crates/shirabe/src/platform/runtime.rs
@@ -3,8 +3,8 @@
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- PhpMixed, class_exists, function_exists, get_loaded_extensions, html_entity_decode, implode,
- instantiate_class, ltrim, phpversion, strip_tags, trim,
+ PhpMixed, class_exists, function_exists, html_entity_decode, implode, instantiate_class, ltrim,
+ strip_tags, trim,
};
/// Seam over the PHP runtime so PlatformRepository can be tested against mocked
@@ -44,9 +44,21 @@ impl RuntimeInterface for Runtime {
fn invoke(&self, callable: PhpMixed, arguments: Vec<PhpMixed>) -> PhpMixed {
// PHP: return $callable(...$arguments);
- // Dispatching an arbitrary PHP callable needs a PHP runtime; no shim exists.
- let _ = (callable, arguments);
- todo!()
+ // Only the specific dynamic callables PlatformRepository actually reaches are
+ // wired through php-rpc; arbitrary PHP callables are still unsupported.
+ match (&callable, arguments.as_slice()) {
+ (PhpMixed::String(name), [PhpMixed::String(arg)]) if name == "inet_pton" => {
+ shirabe_php_rpc::inet_pton(arg)
+ }
+ (PhpMixed::String(name), []) if name == "curl_version" => {
+ let mut version = IndexMap::new();
+ if let Some(v) = shirabe_php_rpc::curl_version() {
+ version.insert("version".to_string(), PhpMixed::String(v));
+ }
+ PhpMixed::Array(version)
+ }
+ _ => todo!(),
+ }
}
fn has_class(&self, class: &str) -> bool {
@@ -62,18 +74,15 @@ impl RuntimeInterface for Runtime {
}
fn get_extensions(&self) -> Vec<String> {
- get_loaded_extensions()
+ shirabe_php_rpc::get_loaded_extensions()
}
fn get_extension_version(&self, extension: &str) -> String {
- let version = phpversion(extension);
- version.unwrap_or_else(|| "0".to_string())
+ shirabe_php_rpc::phpversion(extension).unwrap_or_else(|| "0".to_string())
}
fn get_extension_info(&self, extension: &str) -> anyhow::Result<String> {
- // Depends on \ReflectionExtension::info() and output buffering; no shim equivalent exists.
- let _ = extension;
- todo!()
+ Ok(shirabe_php_rpc::get_extension_info(extension))
}
}