diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-11 02:39:35 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-11 02:39:35 +0900 |
| commit | 6ae7e0d4b3eaf20e2d2cd3d000cf61ab0c9b6e83 (patch) | |
| tree | e39261f4aa7314fe8c75142670c76591cdaccb92 /crates/shirabe/src/command | |
| parent | 5d3232a80be4b989e89cc7ae4e3642cc5acae030 (diff) | |
| download | php-shirabe-6ae7e0d4b3eaf20e2d2cd3d000cf61ab0c9b6e83.tar.gz php-shirabe-6ae7e0d4b3eaf20e2d2cd3d000cf61ab0c9b6e83.tar.zst php-shirabe-6ae7e0d4b3eaf20e2d2cd3d000cf61ab0c9b6e83.zip | |
feat(console): resolve phase-b TODOs in doRun and IO wiring
Wire up ConsoleIO with HelperSet/QuestionHelper, register the
ErrorHandler with the IO instance, and fall back to a default output
in run(). Replace resolved phase-b TODOs across the console, command,
io, factory, installer, dependency_resolver, and util modules; reclassify
the remaining blockers (typed Symfony command registry, stdin resource
caching) as phase-c.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
| -rw-r--r-- | crates/shirabe/src/command/base_command.rs | 49 | ||||
| -rw-r--r-- | crates/shirabe/src/command/base_dependency_command.rs | 17 | ||||
| -rw-r--r-- | crates/shirabe/src/command/clear_cache_command.rs | 22 | ||||
| -rw-r--r-- | crates/shirabe/src/command/create_project_command.rs | 22 | ||||
| -rw-r--r-- | crates/shirabe/src/command/global_command.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/command/init_command.rs | 28 | ||||
| -rw-r--r-- | crates/shirabe/src/command/outdated_command.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/command/reinstall_command.rs | 17 | ||||
| -rw-r--r-- | crates/shirabe/src/command/require_command.rs | 21 | ||||
| -rw-r--r-- | crates/shirabe/src/command/run_script_command.rs | 22 | ||||
| -rw-r--r-- | crates/shirabe/src/command/script_alias_command.rs | 7 | ||||
| -rw-r--r-- | crates/shirabe/src/command/show_command.rs | 11 |
12 files changed, 163 insertions, 65 deletions
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index b1a1837..9218497 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -287,7 +287,14 @@ pub trait HasBaseCommandData { impl<C: HasBaseCommandData> BaseCommand for C { fn get_application(&self) -> Result<Application> { - // TODO(phase-b): requires inner Symfony Command access + // PHP: parent::getApplication() returns Symfony Command::$application, the back-reference + // set by Application::add() -> $command->setApplication($this) when the command is + // registered. + // TODO(phase-c): the command holds no Application back-reference. Establishing it requires + // (1) modelling the Symfony command registry (add/find/run), which is an intentional + // todo!() stub, and (2) making Application shared (Rc<RefCell<Application>>) with a Weak + // back-edge to break the Application<->command cycle. Until command registration runs, + // there is no application to return. todo!() } @@ -296,12 +303,15 @@ impl<C: HasBaseCommandData> BaseCommand for C { _disable_plugins: Option<bool>, _disable_scripts: Option<bool>, ) -> Result<PartialComposerHandle> { - // TODO(phase-b): depends on Application::get_composer, which is still stubbed. + // PHP: $this->composer ??= $this->getApplication()->getComposer(true, ...). + // TODO(phase-c): blocked on get_application() (see above) — it currently returns an owned + // `Application` by value, which a command cannot hold; a shared Application handle is the + // prerequisite. Application::getComposer itself is already implemented. let _ = RuntimeException { message: String::new(), code: 0, }; - todo!("require_composer pending Application::get_composer") + todo!("require_composer pending get_application() shared-handle support") } fn try_composer( @@ -309,8 +319,10 @@ impl<C: HasBaseCommandData> BaseCommand for C { _disable_plugins: Option<bool>, _disable_scripts: Option<bool>, ) -> Option<PartialComposerHandle> { - // TODO(phase-b): depends on Application::get_composer, which is still stubbed. - todo!("try_composer pending Application::get_composer") + // PHP: try { return $this->requireComposer(...); } catch (\RuntimeException $e) { return null; } + // TODO(phase-c): blocked on get_application() / require_composer (see above) — needs a + // shared Application handle the command can reach. + todo!("try_composer pending get_application() shared-handle support") } fn set_composer(&mut self, composer: PartialComposerHandle) { @@ -329,7 +341,10 @@ impl<C: HasBaseCommandData> BaseCommand for C { fn get_io(&mut self) -> Rc<RefCell<dyn IOInterface>> { if self.io().is_none() { - // TODO(phase-b): requires inner Symfony Application access + // PHP: $this->io = $this->getApplication() instanceof Application + // ? $this->getApplication()->getIO() : new NullIO(); + // TODO(phase-c): the application-IO branch needs get_application() (see above); until + // a shared Application handle exists we take the NullIO fallback (PHP's else branch). *self.io_mut() = Some(Rc::new(RefCell::new(NullIO::new()))); } @@ -348,6 +363,10 @@ impl<C: HasBaseCommandData> BaseCommand for C { output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> Result<()> { // initialize a plugin-enabled Composer instance, either local or global + // PHP also ORs in $this->getApplication()->getDisablePluginsByDefault() / + // getDisableScriptsByDefault(). + // TODO(phase-c): the application-default OR-terms need get_application() (see above); a + // shared Application handle is the prerequisite, so only the input flags are honoured here. let mut disable_plugins = input .borrow() .has_parameter_option(&["--no-plugins"], false); @@ -355,8 +374,6 @@ impl<C: HasBaseCommandData> BaseCommand for C { .borrow() .has_parameter_option(&["--no-scripts"], false); - // TODO(phase-b): requires inner Symfony Application access for disable_plugins_by_default / disable_scripts_by_default - if self.is_self_update_command() { disable_plugins = true; disable_scripts = true; @@ -376,7 +393,10 @@ impl<C: HasBaseCommandData> BaseCommand for C { composer }; if let Some(composer) = composer.as_ref() { - // TODO(phase-b): requires inner Symfony Command get_name access + // PHP: $this->getName() — the Symfony Command's configured name. + // TODO(phase-c): the command name lives in Symfony Command state (set via configure() + // -> setName()), which this port does not yet carry on BaseCommandData; it requires + // the Symfony Command base-class model (intentional todo!() stub). let command_name: String = todo!(); let mut pre_command_run_event = PreCommandRunEvent::new( PluginEvents::PRE_COMMAND_RUN.to_string(), @@ -505,7 +525,10 @@ impl<C: HasBaseCommandData> BaseCommand for C { .borrow() .has_parameter_option(&["--no-scripts"], false); - // TODO(phase-b): requires inner Symfony Application access for disable_plugins_by_default / disable_scripts_by_default + // PHP: if ($app instanceof Application && $app->getDisablePluginsByDefault()) $disablePlugins = true; + // (same for getDisableScriptsByDefault()). + // TODO(phase-c): these application-default overrides need get_application() (see above) — + // a shared Application handle is the prerequisite, so only the passed/flag values apply. let disable_plugins_kind = if disable_plugins { crate::factory::DisablePlugins::All } else { @@ -826,6 +849,8 @@ impl<C: HasBaseCommandData> BaseCommand for C { } } -// TODO(phase-b): bridge BaseCommand to Symfony Command for trait-object container usage. +// TODO(phase-c): bridge BaseCommand to Symfony Command for trait-object container usage. // Cannot blanket-impl a foreign trait for a local generic (orphan rule); each concrete -// command must impl symfony Command itself, or a wrapper type must be introduced. +// command must impl symfony Command itself, or a wrapper type must be introduced. This is the +// same orphan-rule blocker as Application::get_default_commands and is gated on the Symfony +// command-registry model, which is an intentional external-package todo!() stub. diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs index decfd5b..27f3544 100644 --- a/crates/shirabe/src/command/base_dependency_command.rs +++ b/crates/shirabe/src/command/base_dependency_command.rs @@ -40,9 +40,6 @@ pub trait BaseDependencyCommand: BaseCommand { fn colors(&self) -> &[String]; fn colors_mut(&mut self) -> &mut Vec<String>; - // TODO(phase-b): these wrappers existed to forward BaseCommand setters, but they - // shadowed the BaseCommand methods and caused ambiguity. Use BaseCommand directly. - fn do_execute( &mut self, input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, @@ -153,12 +150,12 @@ pub trait BaseDependencyCommand: BaseCommand { FindPackageConstraint::String(text_constraint.clone()), )?; if matched_package.is_none() { + let rm = composer.get_repository_manager(); let mut default_repos = CompositeRepository::new( RepositoryFactory::default_repos( Some(self.get_io()), Some(composer.get_config()), - // TODO(phase-b): get_repository_manager returns &; default_repos needs &mut - Some(todo!("share repository_manager as &mut")), + Some(&mut rm.borrow_mut()), )? .into_values() .collect(), @@ -402,10 +399,12 @@ pub trait BaseDependencyCommand: BaseCommand { "blue".to_string(), ]; for color in self.colors() { - // TODO(phase-b): output.get_formatter() returns &OutputFormatter; set_style needs - // &mut. Need interior mutability or `get_formatter_mut`. - let _ = OutputFormatterStyle::new(Some(color), None, None); - let _ = output.borrow().get_formatter(); + let style = OutputFormatterStyle::new(Some(color), None, None); + output + .borrow() + .get_formatter() + .borrow_mut() + .set_style(color, style); } } diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs index 28b303e..5dbfaa5 100644 --- a/crates/shirabe/src/command/clear_cache_command.rs +++ b/crates/shirabe/src/command/clear_cache_command.rs @@ -3,6 +3,7 @@ use crate::command::{BaseCommand, BaseCommandData, HasBaseCommandData}; use crate::composer; use crate::composer::ComposerHandle; +use crate::console::input::InputOption; use crate::factory::Factory; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -18,8 +19,15 @@ impl ClearCacheCommand { self.set_name("clear-cache"); self.set_aliases(&["clearcache".to_string(), "cc".to_string()]); self.set_description("Clears composer's internal package cache"); - // TODO(phase-b): set_definition requires Vec<Box<dyn InputDefinitionEntry>> - // self.set_definition(...) — InputOption::new arg shapes do not yet match + self.set_definition(&[InputOption::new( + "gc", + None, + Some(InputOption::VALUE_NONE), + "Only run garbage collection, not a full cache clear", + None, + ) + .unwrap() + .into()]); self.set_help( "The <info>clear-cache</info> deletes all cached packages from composer's\n\ cache directory.\n\n\ @@ -32,11 +40,17 @@ impl ClearCacheCommand { _input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { - // TODO(phase-b): port full execute logic once Config sharing model is settled + // PHP: $config = $this->tryComposer()?->getConfig() ?? Factory::createConfig(); then + // iterate the cache-* paths and clear/gc each via Cache. + // TODO(phase-c): two blockers. (1) The first statement calls self.try_composer(), which is + // a deferred todo!() (it needs get_application() -> the Symfony command registry). (2) The + // two config sources differ in ownership — composer.get_config() is Rc<RefCell<Config>> + // while Factory::create_config() returns an owned Config — so a shared Config model is + // needed before the per-path Cache logic can read both uniformly. let _ = composer::VERSION; let _: IndexMap<String, String> = IndexMap::new(); let _ = Factory::create_config(None, None); - todo!("phase-b: ClearCacheCommand::execute requires Config sharing strategy") + todo!("ClearCacheCommand::execute pending try_composer + Config sharing model") } } diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index bf00371..ba384d5 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -768,14 +768,16 @@ impl CreateProjectCommand { indexmap::IndexMap::new(), ); if repositories.is_none() { - // TODO(phase-b): default_repos needs &mut RepositoryManager but we hold &RepositoryManager. - let _ = rm; repository_set.add_repository(crate::repository::RepositoryInterfaceHandle::new( CompositeRepository::new( - RepositoryFactory::default_repos(Some(io.clone()), Some(config.clone()), None)? - .into_iter() - .map(|(_, v)| v) - .collect(), + RepositoryFactory::default_repos( + Some(io.clone()), + Some(config.clone()), + Some(&mut rm.borrow_mut()), + )? + .into_iter() + .map(|(_, v)| v) + .collect(), ), ))?; } else { @@ -903,6 +905,7 @@ impl CreateProjectCommand { let mut signal_handler: Option<SignalHandler> = None; if let Some(real_dir) = realpath(&directory) { let real_dir_clone = real_dir.clone(); + let io_for_signal = io.clone(); signal_handler = Some(SignalHandler::create( vec![ SignalHandler::SIGINT.to_string(), @@ -910,8 +913,11 @@ impl CreateProjectCommand { SignalHandler::SIGHUP.to_string(), ], Box::new(move |signal: String, handler: &SignalHandler| { - // TODO(phase-b): self.get_io().write_error(...) inside the closure - let _ = &signal; + io_for_signal.write_error3( + &format!("Received {}, aborting", signal), + true, + crate::io::DEBUG, + ); let mut fs = Filesystem::new(None); fs.remove_directory(&real_dir_clone).ok(); handler.exit_with_last_signal(); diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index fa52adc..f066721 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -76,13 +76,11 @@ impl GlobalCommand { return self.run(input, output); } - // TODO(phase-b): sub_input/output need to be &mut for Application::run; placeholder marks. - let mut sub_input = self.prepare_subcommand_input(input, false)?; + let sub_input = self.prepare_subcommand_input(input, false)?; let mut app = self.get_application()?; - let _ = output; Ok(app.run( Some(std::rc::Rc::new(std::cell::RefCell::new(sub_input))), - None, + Some(output), )?) } diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index 8e200f0..1bafd74 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -448,8 +448,10 @@ impl InitCommand { _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> Result<()> { let io = self.get_io(); - // @var FormatterHelper $formatter - // TODO(phase-b): get_helper_set returns PhpMixed; the helper set needs proper typing. + // @var FormatterHelper $formatter — PHP: $this->getHelperSet()->get('formatter') + // TODO(phase-c): get_helper_set returns PhpMixed and HelperSet::get is a todo!() stub (per + // the "Symfony stays todo!()" policy), so the typed FormatterHelper cannot be retrieved + // until the Helper trait + typed HelperSet are modelled. let formatter: FormatterHelper = todo!(); let _ = &formatter; let _ = self.get_helper_set(); @@ -630,7 +632,13 @@ impl InitCommand { String::new() } ), - // TODO(phase-b): closure cannot call &self.parse_author_string; needs &self capture + // PHP: function ($value) use ($self, $author) { ... $author = $self->parseAuthorString($value); ... } + // TODO(phase-c): IOInterface::ask_and_validate takes a `Box<dyn Fn> + 'static` + // validator, so it cannot borrow &self to call self.parse_author_string; and + // ask_and_validate itself is a deferred QuestionHelper todo!() (see console_io). The + // validator body below therefore stays a placeholder. (parse_author_string and + // is_valid_email are stateless, so a future fix can make them associated functions and + // call them from the closure once the helper interaction is modelled.) Box::new(move |value: PhpMixed| -> anyhow::Result<PhpMixed> { let value_str = value.as_string().unwrap_or("").to_string(); if value_str == "n" || value_str == "no" { @@ -641,7 +649,10 @@ impl InitCommand { } else { value_str }; - // TODO(phase-b): would call self.parse_author_string(value_or_default) + // PHP: $author = $self->parseAuthorString($value); return $author['email'] === null + // ? $author['name'] : sprintf('%s <%s>', $author['name'], $author['email']); + // TODO(phase-c): see the closure note above — cannot reach parse_author_string from + // this 'static validator yet. let _ = value_or_default; Ok(PhpMixed::Null) }), @@ -1083,7 +1094,10 @@ impl InitCommand { let result = self.get_application().and_then(|mut app| { let _update_command = app.find("update")?; app.reset_composer(); - // TODO(phase-b): invoke update_command.run; currently update_command is a PhpMixed. + // PHP: $updateCommand->run(new ArrayInput([]), $output); + // TODO(phase-c): Application::find returns PhpMixed (the Symfony command registry is a + // todo!() stub), so the resolved command's run() cannot be invoked until the typed + // command registry is modelled. let _ = ArrayInput::new(IndexMap::new(), None); let _ = output; Ok(()) @@ -1104,7 +1118,9 @@ impl InitCommand { let result = self.get_application().and_then(|mut app| { let _command = app.find("dump-autoload")?; app.reset_composer(); - // TODO(phase-b): invoke command.run; currently command is a PhpMixed. + // PHP: $command->run(new ArrayInput([]), $output); + // TODO(phase-c): same blocker as update_dependencies — Application::find returns + // PhpMixed (Symfony command registry todo!() stub), so run() cannot be invoked. let _ = ArrayInput::new(IndexMap::new(), None); let _ = output; Ok(()) diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs index 6511b2b..8eb67e6 100644 --- a/crates/shirabe/src/command/outdated_command.rs +++ b/crates/shirabe/src/command/outdated_command.rs @@ -180,9 +180,9 @@ impl OutdatedCommand { let input = ArrayInput::new(args, None); - // TODO(phase-b): convert ArrayInput/output references to dyn trait objects expected by Application::run - let _ = input; - self.get_application()?.run(None, None) + let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(input)); + self.get_application()?.run(Some(input), Some(output)) } pub fn is_proxy_command(&self) -> bool { diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs index e56e24b..e6cbac1 100644 --- a/crates/shirabe/src/command/reinstall_command.rs +++ b/crates/shirabe/src/command/reinstall_command.rs @@ -226,8 +226,13 @@ impl ReinstallCommand { indexmap::IndexMap::new(), ); - // TODO(phase-b): InstallationManager::execute needs `&mut dyn InstalledRepositoryInterface`; - // local_repo is borrowed shared from RepositoryManager. Needs Rc<RefCell<dyn ...>> migration. + // PHP: $installationManager->execute($localRepo, $uninstallOperations, $devMode); + // $installationManager->execute($localRepo, $installOperations, $devMode); + // TODO(phase-c): two blockers. (1) execute() wants `&mut dyn InstalledRepositoryInterface`, + // but local_repo is a RepositoryInterfaceHandle that exposes no raw &mut + // InstalledRepositoryInterface view (only per-method helpers). (2) InstallationManager:: + // execute is itself deferred (its operation/promise machinery stays todo!() — see + // installation_manager.rs). let _ = ( uninstall_operations, install_operations, @@ -281,7 +286,13 @@ impl ReinstallCommand { .as_bool() .unwrap_or(false); - // TODO(phase-b): AutoloadGenerator setters/dump need &mut self; conflicts with concurrent borrows of composer subsystems; needs shared-ownership refactor + // PHP: $generator = $composer->getAutoloadGenerator(); $generator->setClassMapAuthoritative(...); + // $generator->setApcu(...); $generator->setPlatformRequirementFilter(...); + // $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize); + // TODO(phase-c): AutoloadGenerator::dump (and the setters) take &mut self and dump wants + // `local_repo: &mut dyn InstalledRepositoryInterface`, which the RepositoryInterfaceHandle + // does not expose as a raw &mut view (the same handle blocker as execute above). Wiring + // this needs that accessor plus completing the dump call's remaining arguments. let _ = ( authoritative, apcu, diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 44ab921..3d15f86 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -202,8 +202,14 @@ impl RequireCommand { None }; - // TODO(phase-b): closure captures `self` which requires complex borrow handling; the closure needs - // to call self.get_io().write_error(...), self.revert_composer_file(), and handler.exit_with_last_signal() + // PHP: function ($signal, $handler) use ($io, $self) { + // $io->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG); + // $self->revertComposerFile(); $handler->exitWithLastSignal(); } + // TODO(phase-c): SignalHandler::create takes a `Box<dyn Fn> + 'static` handler that cannot + // borrow &self, but the body must call self.revert_composer_file() (which mutates the + // command's composer.json backup state) and self.get_io(). Faithfully wiring this needs the + // revert state + io shared into the closure (Rc<RefCell<...>>), i.e. the shared-ownership + // rework of the command — the same pattern as InstallationManager::execute's signal handler. let signal_handler = SignalHandler::create( vec![ SignalHandler::SIGINT.to_string(), @@ -211,8 +217,6 @@ impl RequireCommand { SignalHandler::SIGHUP.to_string(), ], Box::new(move |signal: String, handler: &SignalHandler| { - // TODO(phase-b): self.get_io().write_error('Received '.$signal.', aborting', true, io_interface::DEBUG); - // TODO(phase-b): self.revert_composer_file(); let _ = signal; handler.exit_with_last_signal(); }), @@ -733,8 +737,13 @@ impl RequireCommand { let mut composer = crate::command::composer_full_mut(&composer_handle); self.dependency_resolution_completed = false; - // TODO(phase-b): add_listener expects a Callable enum; PHP closure should set - // self.dependency_resolution_completed = true when invoked. + // PHP: $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, + // function () use (&$dependencyResolutionCompleted) { $dependencyResolutionCompleted = true; }, 10000); + // TODO(phase-c): the event dispatcher's Callable::Closure is a placeholder variant that + // stores no actual closure, so the listener that flips dependency_resolution_completed + // cannot be registered. Resolving needs the closure model (Callable holding an Rc<dyn Fn>) + // plus dependency_resolution_completed shared (Rc<RefCell<bool>>) into both the listener + // and this command. composer.get_event_dispatcher().borrow_mut().add_listener( InstallerEvents::PRE_OPERATIONS_EXEC, crate::event_dispatcher::Callable::Closure, diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index ce072e4..9a28b5f 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -190,9 +190,19 @@ impl RunScriptCommand { .get_option("no-dev") .as_bool() .unwrap_or(false); - // TODO(phase-b): ScriptEvent::new takes Composer/IOInterface by value; placeholder construction. - let _ = (script.clone(), &composer, dev_mode); - let has_listeners = false; + let io = self.get_io(); + let event = ScriptEvent::new( + script.clone(), + composer + .as_full() + .expect("require_composer returns a full Composer") + .downgrade(), + io, + dev_mode, + vec![], + IndexMap::new(), + ); + let has_listeners = dispatcher.borrow_mut().has_event_listeners(&event); if !has_listeners { return Err(InvalidArgumentException { message: format!("Script \"{}\" is not defined in this package", script), @@ -272,7 +282,11 @@ impl RunScriptCommand { let mut result: Vec<(String, String)> = vec![]; for (name, _script) in scripts { - // TODO(phase-b): Application::find returns PhpMixed; placeholder description. + // PHP: $cmd = $this->getApplication()->find($name); $description = $cmd->getDescription(); + // TODO(phase-c): Application::find returns PhpMixed (the Symfony command registry is a + // todo!() stub) and get_application() is itself deferred, so the resolved command's + // getDescription() cannot be read; the description stays empty until the typed command + // registry is modelled. let _ = self.get_application()?.find(&name); let description = String::new(); result.push((name, description)); diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs index ef95c7e..5c23e26 100644 --- a/crates/shirabe/src/command/script_alias_command.rs +++ b/crates/shirabe/src/command/script_alias_command.rs @@ -37,7 +37,12 @@ impl ScriptAliasCommand { } } - // TODO(phase-b): BaseCommand::new() / ignore_validation_errors() not yet ported + // PHP also calls parent::__construct() (Symfony Command base) and + // $this->ignoreValidationErrors(). + // TODO(phase-c): both are Symfony Command base-class operations — the constructor sets up + // the command's name/definition/application state and ignoreValidationErrors() flips a flag + // on it. Composer's BaseCommand carries no such Symfony Command state yet (the Symfony + // Command base is an intentional todo!() stub), so there is nothing to initialize here. Ok(Self { base_command_data: BaseCommandData { composer: None, diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 7cf305d..06abec4 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -2264,11 +2264,12 @@ impl ShowCommand { ]; for color in self.colors.iter() { - let _style = OutputFormatterStyle::new(Some(color.as_str()), None, None); - // TODO(phase-c): OutputInterface::get_formatter returns &OutputFormatter, but - // set_style requires &mut. Resolution requires interior-mutability refactor of - // OutputFormatter wiring across symfony shim. - let _ = (output.borrow().get_formatter(), color); + let style = OutputFormatterStyle::new(Some(color.as_str()), None, None); + output + .borrow() + .get_formatter() + .borrow_mut() + .set_style(color, style); } } |
