aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-autoload
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-03 11:55:03 +0900
committernsfisis <nsfisis@gmail.com>2026-05-03 11:55:03 +0900
commitae1aa6540761e54a76b8f7984cf93cd3a0d011d0 (patch)
treef111e1c73977f0bffb6323b03f4210269b43b297 /crates/mozart-autoload
parent30ae6c869adc7f3cb87a4d63edd6d0cda89d571d (diff)
downloadphp-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.tar.gz
php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.tar.zst
php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.zip
refactor: switch internal maps/sets from HashMap to IndexMap
Adopt indexmap workspace-wide so iteration order is deterministic and follows insertion order. The non-deterministic order of std HashMap otherwise leaks into resolver decisions when multiple valid solutions exist (e.g. cyclic require pairs under prefer-lowest), making behavior flaky and divergent from Composer's PHP-array semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-autoload')
-rw-r--r--crates/mozart-autoload/Cargo.toml1
-rw-r--r--crates/mozart-autoload/src/autoload.rs7
2 files changed, 5 insertions, 3 deletions
diff --git a/crates/mozart-autoload/Cargo.toml b/crates/mozart-autoload/Cargo.toml
index 98c4f6f..1f1ed5a 100644
--- a/crates/mozart-autoload/Cargo.toml
+++ b/crates/mozart-autoload/Cargo.toml
@@ -7,6 +7,7 @@ edition.workspace = true
mozart-class-map-generator.workspace = true
mozart-registry.workspace = true
anyhow.workspace = true
+indexmap.workspace = true
md5.workspace = true
serde_json.workspace = true
diff --git a/crates/mozart-autoload/src/autoload.rs b/crates/mozart-autoload/src/autoload.rs
index 069fcfa..5e5d702 100644
--- a/crates/mozart-autoload/src/autoload.rs
+++ b/crates/mozart-autoload/src/autoload.rs
@@ -1,7 +1,8 @@
+use indexmap::IndexSet;
use mozart_class_map_generator::{scan_classmap_dirs, scan_psr_for_classmap};
use mozart_registry::installed::InstalledPackages;
use mozart_registry::lockfile::LockedPackage;
-use std::collections::{BTreeMap, HashSet};
+use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
// Embed Composer PHP files from the submodule at compile time.
@@ -470,7 +471,7 @@ fn generate_platform_check(
packages: &[LockedPackage],
root_require: Option<&serde_json::Value>,
mode: &PlatformCheckMode,
- dev_package_names: &HashSet<String>,
+ dev_package_names: &IndexSet<String>,
) -> Option<String> {
if matches!(mode, PlatformCheckMode::Disabled) {
return None;
@@ -934,7 +935,7 @@ pub fn generate(config: &AutoloadConfig) -> anyhow::Result<GenerateResult> {
}
// 4a. Generate platform_check.php if needed
- let dev_package_names_set: HashSet<String> = installed
+ let dev_package_names_set: IndexSet<String> = installed
.dev_package_names
.iter()
.map(|n| n.to_lowercase())