diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-08 04:22:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-08 04:23:11 +0900 |
| commit | 632c9793927a30c4bca3c91888e66b369d732dfe (patch) | |
| tree | 5bafb9d7fa2523d5a2f8d70ff59c3173e962e389 /crates/shirabe/src/autoload | |
| parent | 243450fee9853c2fea66ae0642dabb8db5227d6f (diff) | |
| download | php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.gz php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.zst php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.zip | |
feat(phase-c): resolve PhpMixed-conversion phase-b TODOs
Implement the foundational PhpMixed conversion infrastructure
(From<bool|i64|f64|String>, 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.
Diffstat (limited to 'crates/shirabe/src/autoload')
| -rw-r--r-- | crates/shirabe/src/autoload/class_loader.rs | 59 |
1 files changed, 12 insertions, 47 deletions
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<String, Vec<String>> { if !self.prefixes_psr0.is_empty() { // PHP: call_user_func_array('array_merge', array_values($this->prefixesPsr0)) - let prefixes_as_mixed: IndexMap<String, PhpMixed> = 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<String, Vec<String>> - 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<String, Vec<String>> = 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<String, String>) { 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<String, String> - 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; |
