diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-08 01:54:56 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-08 01:54:56 +0900 |
| commit | 318ea948f5932dfa7942081a269d62fd7161a9bf (patch) | |
| tree | 0fff2fe818f87a20dea89a51901f9e16071f2f53 /crates/shirabe/src/factory.rs | |
| parent | f232d7f9d2936ef84bd904cacd21c12cb7012b34 (diff) | |
| download | php-shirabe-318ea948f5932dfa7942081a269d62fd7161a9bf.tar.gz php-shirabe-318ea948f5932dfa7942081a269d62fd7161a9bf.tar.zst php-shirabe-318ea948f5932dfa7942081a269d62fd7161a9bf.zip | |
feat(phase-c): resolve reflection/downcast phase-b TODOs
Resolve category F phase-b TODOs (class-string, instanceof, get_class,
method_exists, __FILE__, Reflection API, downcast).
- VcsRepository: dispatch drivers through a VcsDriverKind enum
(instantiate/supports/php_class_name) and add constructors to the
concrete VCS drivers
- repository downcasts via RepositoryInterfaceHandle::downcast_rc and
as_any (init/show commands, vcs ValidatingArrayLoader)
- BaseCommand::is_self_update_command override replaces an instanceof
- Factory::create narrows PartialComposer to ComposerHandle via as_full
- InstalledVersions gains set_self_dir/set_installed_is_local_dir,
replacing Reflection-based static property mutation
- ClassLoader::as_array_iter ports the PHP (array) cast
- drop the unnecessary __FILE__ phar branch in self-update
application get_class(command) reclassified TODO(plugin); buffer_io
StreamableInputInterface downcast and the ValidatingArrayLoader trait
redesign left as tracked TODOs.
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.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index ac7c055..c9de808 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -15,7 +15,7 @@ use shirabe_php_shim::{ use crate::autoload::AutoloadGenerator; use crate::cache::Cache; -use crate::composer::{ComposerWeakHandle, PartialOrFullComposer}; +use crate::composer::{ComposerHandle, ComposerWeakHandle, PartialOrFullComposer}; use crate::composer::{PartialComposerHandle, PartialComposerWeakHandle}; use crate::config::Config; use crate::config::JsonConfigSource; @@ -1262,7 +1262,7 @@ impl Factory { config: Option<LocalConfigInput>, disable_plugins: DisablePlugins, disable_scripts: bool, - ) -> anyhow::Result<PartialComposerHandle> { + ) -> anyhow::Result<ComposerHandle> { let factory = Self; // for BC reasons, if a config is passed in either as array or a path that is not the default composer.json path @@ -1285,14 +1285,13 @@ impl Factory { let composer = factory.create_composer(io, config, disable_plugins, None, true, disable_scripts)?; - if !composer.is_full() { - // TODO(phase-b): unreachable when fullLoad=true; downcasting needs design. - return Err(anyhow::anyhow!(RuntimeException { + // fullLoad=true guarantees a full Composer; narrow PartialComposer -> Composer (PHP `: Composer`). + composer.as_full().ok_or_else(|| { + anyhow::anyhow!(RuntimeException { message: "Composer expected with fullLoad=true".to_string(), code: 0, - })); - } - Ok(composer) + }) + }) } /// If you are calling this in a plugin, you probably should instead use `$composer->getLoop()->getHttpDownloader()` |
