diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 08:28:07 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 08:31:02 +0900 |
| commit | 4d974682134f20a816dde717fdbba8e76d9b10b8 (patch) | |
| tree | a9652b651c7412429671206ee77f5a6230f3bd93 | |
| parent | f000cdf5770c3b20bf406367d1d3a65ef215e2fd (diff) | |
| download | php-shirabe-4d974682134f20a816dde717fdbba8e76d9b10b8.tar.gz php-shirabe-4d974682134f20a816dde717fdbba8e76d9b10b8.tar.zst php-shirabe-4d974682134f20a816dde717fdbba8e76d9b10b8.zip | |
refactor(installed-versions): merge the name lists without call_user_func_array
The only live caller passed the constant 'array_merge', so the list
concatenation is written out in place, as ClassLoader::get_prefixes
already does. That leaves the shim function without callers.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| -rw-r--r-- | crates/shirabe-php-shim/src/runtime.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/installed_versions.rs | 19 |
2 files changed, 4 insertions, 21 deletions
diff --git a/crates/shirabe-php-shim/src/runtime.rs b/crates/shirabe-php-shim/src/runtime.rs index 1ca051fb..6ad5bc29 100644 --- a/crates/shirabe-php-shim/src/runtime.rs +++ b/crates/shirabe-php-shim/src/runtime.rs @@ -378,12 +378,6 @@ pub fn memory_get_peak_usage(_real_usage: bool) -> i64 { 0 } -pub fn call_user_func_array(_callback: &str, _args: &PhpMixed) -> PhpMixed { - // TODO(php-runtime): invoking a function by name needs a runtime function registry; the shim has - // no way to resolve a callable from a string. - todo!() -} - pub fn call_php_callable(_callback: &PhpMixed, _args: &[PhpMixed]) -> PhpMixed { // TODO(php-runtime): PhpMixed carries no callable variant; a runtime callable cannot be invoked. todo!() diff --git a/crates/shirabe/src/installed_versions.rs b/crates/shirabe/src/installed_versions.rs index 6d702413..aa934841 100644 --- a/crates/shirabe/src/installed_versions.rs +++ b/crates/shirabe/src/installed_versions.rs @@ -3,8 +3,8 @@ use crate::autoload::ClassLoader; use indexmap::IndexMap; use shirabe_php_shim::{ - OutOfBoundsException, PhpMixed, array_flip, array_keys, array_merge, call_user_func_array, - implode, is_file, method_exists, php_dir, require_php_file, strtr_array, substr, + OutOfBoundsException, PhpMixed, array_flip_strings, array_keys, array_merge, implode, is_file, + method_exists, php_dir, require_php_file, strtr_array, substr, }; use shirabe_semver::VersionParser; use std::sync::Mutex; @@ -48,7 +48,6 @@ impl InstalledVersions { .and_then(|v| v.as_array()) .cloned() .unwrap_or_default(); - // PHP: array_keys($installed['versions']) let keys: Vec<String> = array_keys(&versions); packages.push(keys); } @@ -57,18 +56,8 @@ impl InstalledVersions { return packages.into_iter().next().unwrap(); } - // PHP: array_keys(array_flip(\call_user_func_array('array_merge', $packages))) - let merged = call_user_func_array( - "array_merge", - &PhpMixed::List( - packages - .into_iter() - .map(|p| PhpMixed::List(p.into_iter().map(PhpMixed::String).collect())) - .collect(), - ), - ); - let flipped = array_flip(&merged); - array_keys(&flipped.as_array().cloned().unwrap_or_default()) + let merged: Vec<String> = packages.into_iter().flatten().collect(); + array_keys(&array_flip_strings(&merged)) } /// Returns a list of all package names with a specific type e.g. 'library' |
