diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-04 03:19:52 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-04 15:28:38 +0900 |
| commit | 425eeea92e00ecbfccfc0b13dbc1cfb41d09069c (patch) | |
| tree | f515497c8db83e2aa42d6cc61a6fdd7014035426 /crates/shirabe-php-rpc/src/lib.rs | |
| parent | 1fdbfc1a277a788f8317ed47fccda22c587d3363 (diff) | |
| download | php-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-php-rpc/src/lib.rs')
| -rw-r--r-- | crates/shirabe-php-rpc/src/lib.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/crates/shirabe-php-rpc/src/lib.rs b/crates/shirabe-php-rpc/src/lib.rs index 04583fa..3b0ee66 100644 --- a/crates/shirabe-php-rpc/src/lib.rs +++ b/crates/shirabe-php-rpc/src/lib.rs @@ -33,6 +33,46 @@ pub fn get_constant(name: &str) -> PhpMixed { call("constant", name).unwrap_or(PhpMixed::Null) } +/// PHP `inet_pton($address)`. +pub fn inet_pton(address: &str) -> PhpMixed { + call("inet_pton", address).unwrap_or(PhpMixed::Bool(false)) +} + +/// PHP `curl_version()['version']`. +pub fn curl_version() -> Option<String> { + match call("curl_version", "") { + Some(PhpMixed::String(s)) => Some(s), + _ => None, + } +} + +/// PHP `(new \ReflectionExtension($name))->info()` output. +pub fn get_extension_info(name: &str) -> String { + match call("extension_info", name) { + Some(PhpMixed::String(s)) => s, + _ => String::new(), + } +} + +/// PHP `phpversion($extension)`. +pub fn phpversion(extension: &str) -> Option<String> { + match call("phpversion", extension) { + Some(PhpMixed::String(s)) => Some(s), + _ => None, + } +} + +/// PHP `get_loaded_extensions()`. +/// +/// Extension names are joined with `,` on the PHP side and split back here; real +/// extension names never contain a comma. +pub fn get_loaded_extensions() -> Vec<String> { + match call("get_loaded_extensions", "") { + Some(PhpMixed::String(s)) if !s.is_empty() => s.split(',').map(|s| s.to_string()).collect(), + _ => Vec::new(), + } +} + const GLUE_SCRIPT: &str = include_str!("../php/worker.php"); struct Worker { |
