diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-25 12:16:25 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-25 12:16:25 +0900 |
| commit | 42b5f9e321c918cef542c120ad21ba8a7339eb29 (patch) | |
| tree | 39f2b5a3cb856de9068f72fb670d170c09a2438f /crates/shirabe/tests/repository | |
| parent | f93d9b49382c8f79fcea4f03361d50bda534bcc4 (diff) | |
| download | php-shirabe-42b5f9e321c918cef542c120ad21ba8a7339eb29.tar.gz php-shirabe-42b5f9e321c918cef542c120ad21ba8a7339eb29.tar.zst php-shirabe-42b5f9e321c918cef542c120ad21ba8a7339eb29.zip | |
refactor(operation): replace OperationInterface with AnyOperation enum
Operations are only ever constructed by the dependency resolver, so a
plugin has no way to inject an implementation of its own and the set is
closed. Modelling it as an enum, like AnyPackage, removes the
OperationInterface trait together with its two parallel downcast
mechanisms (as_any() + downcast_ref, and as_*_operation()) and the
get_package() default method that panicked on UpdateOperation.
The PHP idiom `$op instanceof UpdateOperation ? getTargetPackage() :
getPackage()`, written out at six call sites, becomes
AnyOperation::get_target_package(). InstallationManager's three blocks
that matched on the type string and then recovered the type with
expect() collapse into exhaustive matches.
SolverOperation keeps only its TYPE constant; the shared
getOperationType()/__toString() implementations move to AnyOperation,
which also drops the five Self::TYPE.to_string() allocations.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/repository')
| -rw-r--r-- | crates/shirabe/tests/repository/filesystem_repository_test.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/shirabe/tests/repository/filesystem_repository_test.rs b/crates/shirabe/tests/repository/filesystem_repository_test.rs index f2cdb670..054a6d7c 100644 --- a/crates/shirabe/tests/repository/filesystem_repository_test.rs +++ b/crates/shirabe/tests/repository/filesystem_repository_test.rs @@ -3,7 +3,7 @@ use crate::test_case::{get_alias_package, get_package}; use indexmap::IndexMap; use serial_test::serial; -use shirabe::dependency_resolver::operation::OperationInterface; +use shirabe::dependency_resolver::operation::AnyOperation; use shirabe::installed_versions::InstalledVersions; use shirabe::installer::{InstallationManagerInterface, InstallerInterface}; use shirabe::io::IOInterface; @@ -106,7 +106,7 @@ mockall::mock! { fn execute( &mut self, repo: &mut dyn InstalledRepositoryInterface, - operations: Vec<std::rc::Rc<dyn OperationInterface>>, + operations: Vec<AnyOperation>, dev_mode: bool, run_scripts: bool, download_only: bool, |
