aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-22 18:34:48 +0900
committernsfisis <nsfisis@gmail.com>2026-02-22 18:34:48 +0900
commitff0d51089d8c5abc9ecbdeeaf3d6aa152f137e97 (patch)
treeea13f7d87945b7f0b2218a0d6ef6237ad76c9cd7 /crates/mozart-core
parent84d137a19feb1f79f5bd711faff63a6bbe651cbf (diff)
downloadphp-mozart-ff0d51089d8c5abc9ecbdeeaf3d6aa152f137e97.tar.gz
php-mozart-ff0d51089d8c5abc9ecbdeeaf3d6aa152f137e97.tar.zst
php-mozart-ff0d51089d8c5abc9ecbdeeaf3d6aa152f137e97.zip
fix(platform): inject composer pseudo packages into resolver
composer-runtime-api, composer-plugin-api, and composer are Composer pseudo packages that don't exist on Packagist. The resolver was trying to fetch them remotely (HTTP 404) because PackageName::is_platform() didn't recognize them and detect_platform() didn't inject them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-core')
-rw-r--r--crates/mozart-core/src/platform.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crates/mozart-core/src/platform.rs b/crates/mozart-core/src/platform.rs
index c1f187f..cf141a4 100644
--- a/crates/mozart-core/src/platform.rs
+++ b/crates/mozart-core/src/platform.rs
@@ -31,6 +31,17 @@ pub fn is_platform_package(name: &str) -> bool {
// ─── Detection ───────────────────────────────────────────────────────────────
+/// Composer runtime API version that Mozart emulates.
+/// Corresponds to `Composer::RUNTIME_API_VERSION` in Composer.
+pub const COMPOSER_RUNTIME_API_VERSION: &str = "2.2.2";
+
+/// Composer plugin API version that Mozart emulates.
+/// Corresponds to `PluginInterface::PLUGIN_API_VERSION` in Composer.
+pub const COMPOSER_PLUGIN_API_VERSION: &str = "2.6.0";
+
+/// Composer version that Mozart emulates.
+pub const COMPOSER_VERSION: &str = "2.8.0";
+
/// Detect all platform packages by running a single PHP invocation.
///
/// Returns an empty vec if PHP is not found or not executable.
@@ -168,8 +179,36 @@ pub fn parse_platform_info(output: &str) -> Vec<PlatformPackage> {
}
result.extend(packages);
+
+ // Add Composer pseudo packages
+ result.push(PlatformPackage {
+ name: "composer".to_string(),
+ version: COMPOSER_VERSION.to_string(),
+ });
+ result.push(PlatformPackage {
+ name: "composer-plugin-api".to_string(),
+ version: COMPOSER_PLUGIN_API_VERSION.to_string(),
+ });
+ result.push(PlatformPackage {
+ name: "composer-runtime-api".to_string(),
+ version: COMPOSER_RUNTIME_API_VERSION.to_string(),
+ });
+
result
} else {
+ // Even without PHP, provide Composer pseudo packages
+ packages.push(PlatformPackage {
+ name: "composer".to_string(),
+ version: COMPOSER_VERSION.to_string(),
+ });
+ packages.push(PlatformPackage {
+ name: "composer-plugin-api".to_string(),
+ version: COMPOSER_PLUGIN_API_VERSION.to_string(),
+ });
+ packages.push(PlatformPackage {
+ name: "composer-runtime-api".to_string(),
+ version: COMPOSER_RUNTIME_API_VERSION.to_string(),
+ });
packages
}
}
@@ -290,6 +329,11 @@ mod tests {
let ext_ctype = packages.iter().find(|p| p.name == "ext-ctype");
assert!(ext_ctype.is_some());
+
+ // Composer pseudo packages should always be present
+ assert!(packages.iter().any(|p| p.name == "composer"));
+ assert!(packages.iter().any(|p| p.name == "composer-plugin-api"));
+ assert!(packages.iter().any(|p| p.name == "composer-runtime-api"));
}
#[test]