aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/filesystem_repository.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-24 02:54:34 +0900
committernsfisis <nsfisis@gmail.com>2026-07-24 02:54:34 +0900
commit793571b52de57df2b3cde9a3ba6a2823676aba41 (patch)
tree0aee776e11a362edc6420575e1496383bcfdcce4 /crates/shirabe/src/repository/filesystem_repository.rs
parent46a029b338931fd76c8fc44fc13c5774b3657af0 (diff)
downloadphp-shirabe-793571b52de57df2b3cde9a3ba6a2823676aba41.tar.gz
php-shirabe-793571b52de57df2b3cde9a3ba6a2823676aba41.tar.zst
php-shirabe-793571b52de57df2b3cde9a3ba6a2823676aba41.zip
refactor(filesystem-repository): drop eval() shim, defer installed.php reload to PHP runtime
Rust has no PHP interpreter, so eval() can never be ported faithfully. safely_load_installed_versions()'s job of priming Composer\InstalledVersions before plugins run only matters within a single shared PHP process, which the RPC-based plugin architecture does not have; the PHP runtime process can call InstalledVersions::reload() itself instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/filesystem_repository.rs')
-rw-r--r--crates/shirabe/src/repository/filesystem_repository.rs39
1 files changed, 6 insertions, 33 deletions
diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs
index 8f7ce8ea..32bf4728 100644
--- a/crates/shirabe/src/repository/filesystem_repository.rs
+++ b/crates/shirabe/src/repository/filesystem_repository.rs
@@ -22,8 +22,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
Exception, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException,
- array_flip, dirname, r#eval, file_get_contents, get_class_err, get_debug_type, in_array,
- is_array, is_null, is_string, ksort, php_regex, realpath, str_repeat, trim, usort, var_export,
+ array_flip, dirname, file_get_contents, get_class_err, get_debug_type, in_array, is_array,
+ is_null, is_string, ksort, php_regex, realpath, str_repeat, trim, usort, var_export,
};
use shirabe_semver::constraint::AnyConstraint;
@@ -346,37 +346,10 @@ impl FilesystemRepository {
/// As we load the file from vendor dir during bootstrap, we need to make sure it contains only expected code before executing it
///
/// @internal
- pub fn safely_load_installed_versions(path: &str) -> bool {
- // PHP: @file_get_contents($path)
- let installed_versions_data = Silencer::call(|| Ok(file_get_contents(path)))
- .ok()
- .flatten();
- let pattern = "{(?(DEFINE)\n (?<number> -? \\s*+ \\d++ (?:\\.\\d++)? )\n (?<boolean> true | false | null )\n (?<strings> (?&string) (?: \\s*+ \\. \\s*+ (?&string))*+ )\n (?<string> (?: \" (?:[^\"\\\\$]*+ | \\\\ [\"\\\\0] )* \" | ' (?:[^'\\\\]*+ | \\\\ ['\\\\] )* ' ) )\n (?<array> array\\( \\s*+ (?: (?:(?&number)|(?&strings)) \\s*+ => \\s*+ (?: (?:__DIR__ \\s*+ \\. \\s*+)? (?&strings) | (?&value) ) \\s*+, \\s*+ )*+ \\s*+ \\) )\n (?<value> (?: (?&number) | (?&boolean) | (?&strings) | (?&array) ) )\n)\n^<\\?php\\s++return\\s++(?&array)\\s*+;$}ix";
- if let Some(data) = installed_versions_data {
- let mixed = PhpMixed::String(data.clone());
- if is_string(&mixed) && Preg::is_match(pattern, &trim(&data, None)) {
- let replaced = Preg::replace(
- php_regex!(r#"{=>\s*+__DIR__\s*+\.\s*+(['\"])}"#),
- &format!(
- "=> {} . $1",
- var_export(&PhpMixed::String(dirname(path)), true),
- ),
- &data,
- );
- let evaluated = r#eval(&format!("?>{}", replaced));
- InstalledVersions::reload(
- evaluated
- .as_array()
- .cloned()
- .map(|m| m.into_iter().collect())
- .unwrap_or_default(),
- );
-
- return true;
- }
- }
-
- false
+ pub fn safely_load_installed_versions(_path: &str) -> bool {
+ // TODO(php-runtime): call `InstalledVersions::reload()` in PHP runtime process, not in
+ // Rust.
+ true
}
/// @param array<mixed> $array