diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-03 01:57:34 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-03 01:57:34 +0900 |
| commit | 26daafaae3713cd94ce32354e6404d95e06c568c (patch) | |
| tree | c2accce206af3492f12317ff8674acf5444b3425 | |
| parent | 8888e4b8bfeb41e4edd45ab47db8a293e93ded3f (diff) | |
| download | php-shirabe-26daafaae3713cd94ce32354e6404d95e06c568c.tar.gz php-shirabe-26daafaae3713cd94ce32354e6404d95e06c568c.tar.zst php-shirabe-26daafaae3713cd94ce32354e6404d95e06c568c.zip | |
feat(downcast): wire package/repo/filter instanceof checks via existing handle/as_any
Resolve three category-4 TODO(phase-b) placeholders that were short-circuited
to None/true, by routing them through downcast mechanisms that already exist:
- package_sorter: PackageInterfaceHandle::as_root() for the
instanceof RootPackageInterface check that adds dev-requires
- platform_repository::is_complete_package: as_complete().is_some(),
consistent with the inlined check already in add_package
- create_project_command: PlatformRequirementFilterInterface::as_any()
downcast to IgnoreAllPlatformRequirementFilter
No new trait infrastructure introduced.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| -rw-r--r-- | crates/shirabe/src/command/create_project_command.rs | 8 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/platform_repository.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/util/package_sorter.rs | 5 |
3 files changed, 8 insertions, 10 deletions
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index e52fe39..90a4d99 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -830,9 +830,11 @@ impl CreateProjectCommand { format!("stability {}", stability) } ); - // TODO(phase-b): `$platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter` - let is_ignore_all: Option<&IgnoreAllPlatformRequirementFilter> = None; - if is_ignore_all.is_none() + let is_ignore_all = platform_requirement_filter + .as_any() + .downcast_ref::<IgnoreAllPlatformRequirementFilter>() + .is_some(); + if !is_ignore_all && version_selector .find_best_candidate( &name, diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index b8c4f52..0d10e3a 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -1903,9 +1903,8 @@ impl PlatformRepository { // ---- helpers ---- - fn is_complete_package(_package: PackageInterfaceHandle) -> bool { - // TODO(phase-b): use Any-style downcasting once the trait carries it. - true + fn is_complete_package(package: PackageInterfaceHandle) -> bool { + package.as_complete().is_some() } fn resource_bundle_get(_value: &PhpMixed, _key: &str) -> PhpMixed { diff --git a/crates/shirabe/src/util/package_sorter.rs b/crates/shirabe/src/util/package_sorter.rs index 9db56f5..97b2561 100644 --- a/crates/shirabe/src/util/package_sorter.rs +++ b/crates/shirabe/src/util/package_sorter.rs @@ -6,7 +6,6 @@ use shirabe_php_shim::{strnatcasecmp, version_compare}; use crate::package::Link; use crate::package::PackageInterface; use crate::package::PackageInterfaceHandle; -use crate::package::RootPackage; pub struct PackageSorter; @@ -47,9 +46,7 @@ impl PackageSorter { for package in &packages { let mut links: IndexMap<String, Link> = package.get_requires(); - // TODO(phase-b): check for RootAliasPackage as well; PackageInterface lacks as_any - let root_package: Option<&RootPackage> = None; - if let Some(root_package) = root_package { + if let Some(root_package) = package.as_root() { links.extend(root_package.get_dev_requires()); } for link in links.values() { |
