From 632c9793927a30c4bca3c91888e66b369d732dfe Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 8 Jun 2026 04:22:49 +0900 Subject: feat(phase-c): resolve PhpMixed-conversion phase-b TODOs Implement the foundational PhpMixed conversion infrastructure (From, order-sensitive PartialEq matching PHP ===) and resolve the category-G phase-b TODOs that depend on it: - Fix VCS driver cache paths that discarded parsed JSON or diverged on null caches (svn/forgejo/gitlab/git-bitbucket/github). - Wire up real conversions previously stubbed or dropped: suggests platform config, audit ignore-severities, composer_repository search and ProviderInfo, class_loader prefix/classmap merges, locker lock diff comparison, advisory JSON serialization, SPDX license fields. - Make GenericRule take a typed ReasonData; populate RULE_ROOT_REQUIRE with the constraint and convert PhpMixed at the call sites. --- crates/shirabe/src/autoload/class_loader.rs | 59 ++++++----------------------- 1 file changed, 12 insertions(+), 47 deletions(-) (limited to 'crates/shirabe/src/autoload/class_loader.rs') diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs index 99ee5c2..745e9f2 100644 --- a/crates/shirabe/src/autoload/class_loader.rs +++ b/crates/shirabe/src/autoload/class_loader.rs @@ -79,37 +79,16 @@ impl ClassLoader { pub fn get_prefixes(&self) -> IndexMap> { if !self.prefixes_psr0.is_empty() { // PHP: call_user_func_array('array_merge', array_values($this->prefixesPsr0)) - let prefixes_as_mixed: IndexMap = self - .prefixes_psr0 - .iter() - .map(|(k, v)| { - ( - k.clone(), - PhpMixed::Array( - v.iter() - .map(|(k2, v2)| { - ( - k2.clone(), - Box::new(PhpMixed::List( - v2.iter() - .map(|s| Box::new(PhpMixed::String(s.clone()))) - .collect(), - )), - ) - }) - .collect(), - ), - ) - }) - .collect(); - let arrays = array_values(&prefixes_as_mixed); - let result = call_user_func_array( - "array_merge", - &PhpMixed::List(arrays.into_iter().map(Box::new).collect()), - ); - // TODO(phase-b): cast result back to IndexMap> - let _ = result; - return IndexMap::new(); + // The per-first-char maps are flattened into one prefix => dirs map. array_merge with + // string keys keeps the first position and lets the later value win, which is exactly + // IndexMap::insert. + let mut result: IndexMap> = IndexMap::new(); + for inner in self.prefixes_psr0.values() { + for (prefix, dirs) in inner { + result.insert(prefix.clone(), dirs.clone()); + } + } + return result; } IndexMap::new() @@ -139,22 +118,8 @@ impl ClassLoader { pub fn add_class_map(&mut self, class_map: IndexMap) { if !self.class_map.is_empty() { // PHP: $this->classMap = array_merge($this->classMap, $classMap); - let merged = array_merge( - PhpMixed::Array( - self.class_map - .iter() - .map(|(k, v)| (k.clone(), Box::new(PhpMixed::String(v.clone())))) - .collect(), - ), - PhpMixed::Array( - class_map - .iter() - .map(|(k, v)| (k.clone(), Box::new(PhpMixed::String(v.clone())))) - .collect(), - ), - ); - // TODO(phase-b): cast merged back to IndexMap - let _ = merged; + // array_merge keeps existing string keys in place and lets $classMap overwrite their + // values while appending new ones, which is exactly IndexMap::extend. self.class_map.extend(class_map); } else { self.class_map = class_map; -- cgit v1.3.1