From 7d3a88cb55f101f376a6635ea7dcbb0e10eff364 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 05:49:22 +0900 Subject: refactor(autoload): drop deprecated Autoload\ClassMapGenerator impl Composer\Autoload\ClassMapGenerator has been deprecated since Composer 2.4.0 and is no longer referenced by Composer itself, which uses the composer/class-map-generator package directly. Remove its dump/createMap port (and the unwired scanned_files TODO), keeping only the type with a #[deprecated] attribute and a TODO(plugin) note so it can be implemented later for plugins that may still rely on it. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/autoload/class_map_generator.rs | 109 ++++----------------- 1 file changed, 17 insertions(+), 92 deletions(-) (limited to 'crates/shirabe/src/autoload') diff --git a/crates/shirabe/src/autoload/class_map_generator.rs b/crates/shirabe/src/autoload/class_map_generator.rs index 6aa6492..06dc34d 100644 --- a/crates/shirabe/src/autoload/class_map_generator.rs +++ b/crates/shirabe/src/autoload/class_map_generator.rs @@ -1,96 +1,21 @@ //! ref: composer/src/Composer/Autoload/ClassMapGenerator.php -use indexmap::IndexMap; - -use shirabe_class_map_generator::class_map_generator::ClassMapGenerator as ExternalClassMapGenerator; -use shirabe_php_shim::PhpMixed; - -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; - +/// `Composer\Autoload\ClassMapGenerator`. +/// +/// Deprecated since Composer 2.4.0 in favor of the composer/class-map-generator +/// package (`shirabe-class-map-generator`), which Composer itself now uses +/// directly. Composer's own code no longer references this class, so its +/// `dump` / `createMap` methods are intentionally left unported. +/// +/// Even though it is deprecated, plugins may still use it, so this type will +/// eventually have to be implemented alongside plugin API support. It is left +/// here intentionally so that implementation is not forgotten. +/// +/// TODO(plugin): implement `dump` / `createMap` for plugins still relying on +/// this deprecated class. #[derive(Debug)] +#[deprecated( + since = "Composer 2.4.0", + note = "use the composer/class-map-generator package (shirabe-class-map-generator) instead" +)] pub struct ClassMapGenerator; - -impl ClassMapGenerator { - pub fn dump(dirs: Vec, file: &str) -> anyhow::Result<()> { - let mut maps: IndexMap = IndexMap::new(); - for dir in dirs { - maps.extend(ClassMapGenerator::create_map( - PhpMixed::String(dir), - None, - None, - None, - None, - &mut IndexMap::new(), - )?); - } - let maps_php = PhpMixed::Array( - maps.into_iter() - .map(|(k, v)| (k, Box::new(PhpMixed::String(v)))) - .collect(), - ); - std::fs::write( - file, - format!( - ", - mut io: Option>>, - namespace: Option, - autoload_type: Option, - scanned_files: &mut IndexMap, - ) -> anyhow::Result> { - let _ = scanned_files; - let mut generator = ExternalClassMapGenerator::new(vec![ - "php".to_string(), - "inc".to_string(), - "hh".to_string(), - ]); - // TODO(phase-b): scanned_files tracking via avoid_duplicate_scans not wired up - generator.avoid_duplicate_scans(None); - - generator.scan_paths( - path, - excluded, - autoload_type.as_deref().unwrap_or("classmap"), - namespace, - vec![], - )?; - - let class_map = generator.get_class_map(); - - if let Some(io) = io.as_mut() { - for msg in class_map.get_psr_violations() { - io.write_error(&format!("{}", msg)); - } - - for (class, paths) in class_map.get_ambiguous_classes(None)? { - if paths.len() > 1 { - io.write_error(&format!( - "Warning: Ambiguous class resolution, \"{}\" was found {}x: in \"{}\" and \"{}\", the first will be used.", - class, - paths.len() + 1, - class_map.get_class_path(&class).unwrap_or(""), - paths.join("\", \""), - )); - } else { - io.write_error(&format!( - "Warning: Ambiguous class resolution, \"{}\" was found in both \"{}\" and \"{}\", the first will be used.", - class, - class_map.get_class_path(&class).unwrap_or(""), - paths.join("\", \""), - )); - } - } - } - - Ok(class_map.get_map().clone()) - } -} -- cgit v1.3.1