aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/platform_repository.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-06 20:38:19 +0900
committernsfisis <nsfisis@gmail.com>2026-08-06 20:38:19 +0900
commit91e7102d02cfcda0bf1b82ae1b3fb30900495360 (patch)
tree36be9051ad3a0a12c72ec4ab2afb2359b8983c65 /crates/shirabe/src/repository/platform_repository.rs
parenta7bd624b3e9d4e9493435be1e6016303830e7087 (diff)
downloadphp-shirabe-91e7102d02cfcda0bf1b82ae1b3fb30900495360.tar.gz
php-shirabe-91e7102d02cfcda0bf1b82ae1b3fb30900495360.tar.zst
php-shirabe-91e7102d02cfcda0bf1b82ae1b3fb30900495360.zip
fix(platform-repository): report the icu and imagick libraries
PlatformRepository probes ResourceBundle, IntlChar and Imagick to derive lib-icu-cldr, lib-icu-unicode and lib-imagick-imagemagick. Those probes ran against the shim's hard-coded class_exists allowlist, which never names them, so the packages were silently missing: on a machine with intl, `show --platform` listed fewer libraries than upstream Composer does. The runtime seam now asks the real PHP: hasClass over RPC, and construct / invoke through the worker for the three classes PlatformRepository reaches. A live PHP object has no PhpMixed counterpart, so the seam answers with the entries the caller reads off it. The seam's own callers read those entries instead of returning null and the empty string. Two addLibrary calls also had replaces and provides swapped, dropping `lib-libxslt replaces lib-xsl` and `lib-zip-libzip replaces lib-zip`. `show --platform` now matches upstream Composer byte for byte, and all 59 provideLibraryTestCases datasets pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/platform_repository.rs')
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 3f22954c..5b205ba0 100644
--- a/crates/shirabe/src/repository/platform_repository.rs
+++ b/crates/shirabe/src/repository/platform_repository.rs
@@ -1378,8 +1378,8 @@ impl PlatformRepository {
"libxslt",
libxslt_str.as_deref(),
None,
- &[],
&["xsl".to_string()],
+ &[],
)?;
let info = self.runtime.get_extension_info("xsl")?;
@@ -1443,8 +1443,8 @@ impl PlatformRepository {
&format!("{}-libzip", name),
libzip_str.as_deref(),
None,
- &[],
&["zip".to_string()],
+ &[],
)?;
}
}
@@ -1839,14 +1839,25 @@ impl PlatformRepository {
package.as_complete().is_some()
}
- fn resource_bundle_get(_value: &PhpMixed, _key: &str) -> PhpMixed {
- // TODO(plugin): proper ResourceBundle::get($key) dispatch on a PHP object.
- PhpMixed::Null
+ /// PHP `$resourceBundle->get($key)`. A live PHP object has no `PhpMixed` counterpart, so
+ /// [`RuntimeInterface`] answers with the entries the caller reads instead of the object.
+ fn resource_bundle_get(value: &PhpMixed, key: &str) -> PhpMixed {
+ Self::php_object_field(value, key).unwrap_or(PhpMixed::Null)
}
- fn imagick_get_version_string(_value: &PhpMixed) -> String {
- // TODO(plugin): proper Imagick->getVersion()['versionString'] dispatch.
- "".to_string()
+ /// PHP `$imagick->getVersion()['versionString']`, read the same way.
+ fn imagick_get_version_string(value: &PhpMixed) -> String {
+ match Self::php_object_field(value, "versionString") {
+ Some(PhpMixed::String(version)) => version,
+ _ => String::new(),
+ }
+ }
+
+ fn php_object_field(value: &PhpMixed, key: &str) -> Option<PhpMixed> {
+ match value {
+ PhpMixed::Object(fields) | PhpMixed::Array(fields) => fields.get(key).cloned(),
+ _ => None,
+ }
}
fn php_array_to_string_vec(value: &PhpMixed) -> Vec<String> {