aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-php-rpc/src/lib.rs13
-rw-r--r--crates/shirabe-php-shim/src/stream.rs7
-rw-r--r--crates/shirabe/src/autoload/class_loader.rs3
3 files changed, 15 insertions, 8 deletions
diff --git a/crates/shirabe-php-rpc/src/lib.rs b/crates/shirabe-php-rpc/src/lib.rs
index 1b165cfa..b11351e6 100644
--- a/crates/shirabe-php-rpc/src/lib.rs
+++ b/crates/shirabe-php-rpc/src/lib.rs
@@ -537,6 +537,19 @@ pub fn phpversion(extension: &str) -> Option<String> {
}
}
+/// PHP `stream_resolve_include_path($filename)`. It is answered by the worker because the
+/// `include_path` it searches is the worker's own, including whatever a required `autoload_real.php`
+/// put there with `set_include_path()`.
+pub fn stream_resolve_include_path(filename: &str) -> Option<String> {
+ match call("stream_resolve_include_path", filename) {
+ PhpMixed::String(s) => Some(s),
+ PhpMixed::Bool(false) => None,
+ other => {
+ panic!("PHP RPC: `stream_resolve_include_path` returned an unexpected value: {other:?}")
+ }
+ }
+}
+
/// What `Composer\XdebugHandler\XdebugHandler::getAllIniFiles()` measures: `[(string)
/// php_ini_loaded_file()]` merged with the trimmed, comma-split `php_ini_scanned_files()` list
/// when scanning is active. The worker runs on the ini files of the machine, so these are the
diff --git a/crates/shirabe-php-shim/src/stream.rs b/crates/shirabe-php-shim/src/stream.rs
index b699b0ae..6ecf80f5 100644
--- a/crates/shirabe-php-shim/src/stream.rs
+++ b/crates/shirabe-php-shim/src/stream.rs
@@ -13,13 +13,6 @@ pub fn stream_get_contents(stream: &PhpResource) -> Option<String> {
stream_read_remaining(stream, None)
}
-pub fn stream_resolve_include_path(filename: impl AsRef<std::path::Path>) -> Option<String> {
- // TODO(phase-c): resolution searches the `include_path` ini setting, which the shim does not
- // model; checking only the current directory would silently miss configured include paths.
- let _ = filename.as_ref();
- todo!()
-}
-
// Reads from the stream's current position: all remaining bytes, or up to `max_length` when given
// (a negative max means "until end").
fn stream_read_remaining(stream: &PhpResource, max_length: Option<i64>) -> Option<String> {
diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs
index 023812ce..2d888ecf 100644
--- a/crates/shirabe/src/autoload/class_loader.rs
+++ b/crates/shirabe/src/autoload/class_loader.rs
@@ -1,9 +1,10 @@
//! ref: composer/src/Composer/Autoload/ClassLoader.php
use indexmap::IndexMap;
+use shirabe_php_rpc::stream_resolve_include_path;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, defined, file_exists, include_file, spl_autoload_register,
- spl_autoload_unregister, stream_resolve_include_path, strlen, strpos, strrpos, strtr, substr,
+ spl_autoload_unregister, strlen, strpos, strrpos, strtr, substr,
};
use std::sync::{LazyLock, Mutex};