From 318ea948f5932dfa7942081a269d62fd7161a9bf Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 8 Jun 2026 01:54:56 +0900 Subject: 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) --- crates/shirabe/src/repository/filesystem_repository.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/repository/filesystem_repository.rs') diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 4e752d9..bb78886 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -341,14 +341,8 @@ impl FilesystemRepository { // make sure the selfDir matches the expected data at runtime if the class was loaded from the vendor dir, as it may have been // loaded from the Composer sources, causing packages to appear twice in that case if the installed.php is loaded in addition to the // in memory loaded data from above - // TODO(phase-b): Reflection API on static properties — confirm porting approach with user - let _attempt: Result<()> = (|| -> Result<()> { - todo!( - "ReflectionProperty(Composer\\InstalledVersions::class, 'selfDir')->setValue(null, strtr($repoDir, '\\\\', '/'))" - ); - // (the second reflection block sets installedIsLocalDir = true) - })(); - // PHP: catches \ReflectionException and rethrows if not "Property does not exist" + InstalledVersions::set_self_dir(repo_dir.replace('\\', "/")); + InstalledVersions::set_installed_is_local_dir(true); } } -- cgit v1.3.1