diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-19 00:10:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-19 00:11:03 +0900 |
| commit | c839244d8d09f3036ebfee8eef7eb6b147e593ab (patch) | |
| tree | fe48c94f2c2e62468beef5ff1a8f3cff6adeef4f /crates/shirabe/src/command/dump_autoload_command.rs | |
| parent | 48839250146b217e2756ed3c0e624fd341b54d6c (diff) | |
| download | php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.gz php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.zst php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.zip | |
fix(compile): fix various compile errors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/dump_autoload_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/dump_autoload_command.rs | 92 |
1 files changed, 32 insertions, 60 deletions
diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs index 43af30d..9389132 100644 --- a/crates/shirabe/src/command/dump_autoload_command.rs +++ b/crates/shirabe/src/command/dump_autoload_command.rs @@ -1,13 +1,11 @@ //! ref: composer/src/Composer/Command/DumpAutoloadCommand.php use anyhow::Result; -use shirabe_external_packages::symfony::component::console::command::command::Command; -use shirabe_external_packages::symfony::component::console::command::command::CommandBase; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; -use crate::command::base_command::BaseCommand; +use crate::command::base_command::{BaseCommand, BaseCommandData, HasBaseCommandData}; use crate::composer::Composer; use crate::console::input::input_option::InputOption; use crate::io::io_interface::IOInterface; @@ -16,29 +14,27 @@ use crate::plugin::plugin_events::PluginEvents; #[derive(Debug)] pub struct DumpAutoloadCommand { - inner: CommandBase, - composer: Option<Composer>, - io: Option<Box<dyn IOInterface>>, + base_command_data: BaseCommandData, } impl DumpAutoloadCommand { pub fn configure(&mut self) { - self.inner + self .set_name("dump-autoload") - .set_aliases(vec!["dumpautoload".to_string()]) + .set_aliases(&["dumpautoload".to_string()]) .set_description("Dumps the autoloader") .set_definition(vec![ - InputOption::new("optimize", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.", None, vec![]), - InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize`.", None, vec![]), - InputOption::new("apcu", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None, vec![]), - InputOption::new("apcu-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu", None, vec![]), - InputOption::new("dry-run", None, Some(InputOption::VALUE_NONE), "Outputs the operations but will not execute anything.", None, vec![]), - InputOption::new("dev", None, Some(InputOption::VALUE_NONE), "Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.", None, vec![]), - InputOption::new("no-dev", None, Some(InputOption::VALUE_NONE), "Disables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.", None, vec![]), - InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None, vec![]), - InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages).", None, vec![]), - InputOption::new("strict-psr", None, Some(InputOption::VALUE_NONE), "Return a failed status code (1) if PSR-4 or PSR-0 mapping errors are present. Requires --optimize to work.", None, vec![]), - InputOption::new("strict-ambiguous", None, Some(InputOption::VALUE_NONE), "Return a failed status code (2) if the same class is found in multiple files. Requires --optimize to work.", None, vec![]), + InputOption::new("optimize", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.", None), + InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize`.", None), + InputOption::new("apcu", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None), + InputOption::new("apcu-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu", None), + InputOption::new("dry-run", None, Some(InputOption::VALUE_NONE), "Outputs the operations but will not execute anything.", None), + InputOption::new("dev", None, Some(InputOption::VALUE_NONE), "Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.", None), + InputOption::new("no-dev", None, Some(InputOption::VALUE_NONE), "Disables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.", None), + InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None), + InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages).", None), + InputOption::new("strict-psr", None, Some(InputOption::VALUE_NONE), "Return a failed status code (1) if PSR-4 or PSR-0 mapping errors are present. Requires --optimize to work.", None), + InputOption::new("strict-ambiguous", None, Some(InputOption::VALUE_NONE), "Return a failed status code (2) if the same class is found in multiple files. Requires --optimize to work.", None), ]) .set_help( "<info>php composer.phar dump-autoload</info>\n\n\ @@ -47,20 +43,20 @@ impl DumpAutoloadCommand { } pub fn execute(&self, input: &dyn InputInterface, output: &dyn OutputInterface) -> Result<i64> { - let composer = self.inner.require_composer()?; + let composer = self.require_composer(None, None)?; // TODO(plugin): dispatch CommandEvent let command_event = CommandEvent::new( PluginEvents::COMMAND.to_string(), "dump-autoload".to_string(), - Box::new(input), - Box::new(output), + input, + output, vec![], vec![], ); composer .get_event_dispatcher() - .dispatch(command_event.get_name(), &command_event); + .dispatch(Some(command_event.get_name()), None); let installation_manager = composer.get_installation_manager(); let local_repo = composer.get_repository_manager().get_local_repository(); @@ -72,7 +68,7 @@ impl DumpAutoloadCommand { let install_path = installation_manager.get_install_path(&*local_pkg); if install_path.as_deref().is_some_and(|p| !file_exists(p)) { missing_dependencies = true; - self.inner.get_io().write("<warning>Not all dependencies are installed. Make sure to run a \"composer install\" to install missing dependencies</warning>"); + self.get_io().write("<warning>Not all dependencies are installed. Make sure to run a \"composer install\" to install missing dependencies</warning>"); break; } } @@ -118,16 +114,13 @@ impl DumpAutoloadCommand { } if authoritative { - self.inner - .get_io() + self.get_io() .write("<info>Generating optimized autoload files (authoritative)</info>"); } else if optimize { - self.inner - .get_io() + self.get_io() .write("<info>Generating optimized autoload files</info>"); } else { - self.inner - .get_io() + self.get_io() .write("<info>Generating autoload files</info>"); } @@ -153,8 +146,7 @@ impl DumpAutoloadCommand { generator.set_class_map_authoritative(authoritative); generator.set_run_scripts(true); generator.set_apcu(apcu, apcu_prefix.as_deref()); - generator - .set_platform_requirement_filter(self.inner.get_platform_requirement_filter(input)?); + generator.set_platform_requirement_filter(self.get_platform_requirement_filter(input)?); let class_map = generator.dump( config, &local_repo, @@ -172,16 +164,14 @@ impl DumpAutoloadCommand { let number_of_classes = class_map.len(); if authoritative { - self.inner.get_io().write(&format!("<info>Generated optimized autoload files (authoritative) containing {} classes</info>", number_of_classes)); + self.get_io().write(&format!("<info>Generated optimized autoload files (authoritative) containing {} classes</info>", number_of_classes)); } else if optimize { - self.inner.get_io().write(&format!( + self.get_io().write(&format!( "<info>Generated optimized autoload files containing {} classes</info>", number_of_classes )); } else { - self.inner - .get_io() - .write("<info>Generated autoload files</info>"); + self.get_io().write("<info>Generated autoload files</info>"); } if missing_dependencies @@ -204,30 +194,12 @@ impl DumpAutoloadCommand { } } -impl BaseCommand for DumpAutoloadCommand { - fn inner(&self) -> &CommandBase { - &self.inner +impl HasBaseCommandData for DumpAutoloadCommand { + fn base_command_data(&self) -> &BaseCommandData { + &self.base_command_data } - fn inner_mut(&mut self) -> &mut CommandBase { - &mut self.inner - } - - fn composer(&self) -> Option<&Composer> { - self.composer.as_ref() - } - - fn composer_mut(&mut self) -> &mut Option<Composer> { - &mut self.composer - } - - fn io(&self) -> Option<&dyn IOInterface> { - self.io.as_deref() - } - - fn io_mut(&mut self) -> &mut Option<Box<dyn IOInterface>> { - &mut self.io + fn base_command_data_mut(&mut self) -> &mut BaseCommandData { + &mut self.base_command_data } } - -impl Command for DumpAutoloadCommand {} |
