aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/factory.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-11 02:39:35 +0900
committernsfisis <nsfisis@gmail.com>2026-06-11 02:39:35 +0900
commit6ae7e0d4b3eaf20e2d2cd3d000cf61ab0c9b6e83 (patch)
treee39261f4aa7314fe8c75142670c76591cdaccb92 /crates/shirabe/src/factory.rs
parent5d3232a80be4b989e89cc7ae4e3642cc5acae030 (diff)
downloadphp-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/factory.rs')
-rw-r--r--crates/shirabe/src/factory.rs44
1 files changed, 34 insertions, 10 deletions
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs
index f1c66ce..ab0d389 100644
--- a/crates/shirabe/src/factory.rs
+++ b/crates/shirabe/src/factory.rs
@@ -419,10 +419,13 @@ impl Factory {
}
pub fn create_output() -> ConsoleOutput {
- let _styles = Self::create_additional_styles();
- // TODO(phase-b): OutputFormatter::new signature and ConsoleOutput::new_with_formatter missing
- todo!(
- "create_output: wire OutputFormatter into ConsoleOutput once the symfony console stubs are completed"
+ let styles = Self::create_additional_styles();
+ let formatter = OutputFormatter::new(false, styles);
+
+ ConsoleOutput::new(
+ shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL,
+ None,
+ Some(std::rc::Rc::new(std::cell::RefCell::new(formatter))),
)
}
@@ -678,9 +681,13 @@ impl Factory {
"Composer\\Package\\RootPackage",
Some(&cwd),
)?;
- // TODO(phase-b): set_package expects RootPackageInterface; loader returns BasePackage
- // composer.set_package(package);
- let _ = package;
+ // load() builds a RootPackage of the requested class, so as_root() is always
+ // Some; setPackage takes a RootPackageInterface in PHP.
+ composer.set_package(
+ package
+ .as_root()
+ .expect("RootPackageLoader::load returns a RootPackage"),
+ );
// load local repository
self.add_local_repository(
@@ -853,7 +860,13 @@ impl Factory {
// once everything is initialized we can
// purge packages from local repos if they have been deleted on the filesystem
- // TODO(phase-b): rm and im are owned by composer at this point; need to access via composer
+ // PHP: $this->purgePackages($rm->getLocalRepository(), $im);
+ // TODO(phase-c): the rm/im locals are still in scope (Rc-shared with composer), but
+ // purge_packages wants `&mut dyn InstalledRepositoryInterface` and
+ // RepositoryManager::get_local_repository yields a RepositoryInterfaceHandle that
+ // exposes no raw &mut InstalledRepositoryInterface view (only per-method helpers that
+ // borrow internally). Wiring this needs such an accessor plus completing
+ // purge_packages' removal body (repo.removePackage), which is itself still a stub.
// self.purge_packages(rm.get_local_repository(), &mut im)?;
}
@@ -1219,8 +1232,19 @@ impl Factory {
.unwrap_or_default(),
Some("/"),
);
- // TODO(phase-b): BinaryInstaller is a PHP class so it can't be cloned. Sharing requires
- // Rc<RefCell<BinaryInstaller>>; for now construct one per installer.
+ // PHP: $binaryInstaller = new BinaryInstaller(...);
+ // $im->addInstaller(new LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
+ // $im->addInstaller(new PluginInstaller($io, $composer, $fs, $binaryInstaller));
+ // $im->addInstaller(new MetapackageInstaller($io));
+ // The same BinaryInstaller object is shared by the Library and Plugin installers.
+ // TODO(phase-c): two coupled blockers. (1) Sharing one BinaryInstaller requires
+ // Rc<RefCell<BinaryInstaller>>; LibraryInstaller/PluginInstaller currently own a
+ // `BinaryInstaller` by value. (2) Both installers' constructors take a
+ // PartialComposerWeakHandle, but create_default_installers runs (line 737) before the
+ // composer is wrapped in its shared Rc, so no weak handle is obtainable here yet —
+ // installer registration must move after the composer Rc is established. Both are part of
+ // the composer construction-ordering / shared-ownership rework, so no installers are
+ // registered for now.
let _binary_installer = BinaryInstaller::new(
io.clone(),
bin_dir.clone(),