diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-19 21:46:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-19 21:46:08 +0900 |
| commit | 5e31fa33c3b5cf726a57a063b8e7a070869250fe (patch) | |
| tree | 98522466966fa7df483cad174ab5fc03db39bc09 /crates/shirabe/src/command/package_discovery_trait.rs | |
| parent | c839244d8d09f3036ebfee8eef7eb6b147e593ab (diff) | |
| download | php-shirabe-5e31fa33c3b5cf726a57a063b8e7a070869250fe.tar.gz php-shirabe-5e31fa33c3b5cf726a57a063b8e7a070869250fe.tar.zst php-shirabe-5e31fa33c3b5cf726a57a063b8e7a070869250fe.zip | |
fix(compile): fix more random compile errors
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/package_discovery_trait.rs')
| -rw-r--r-- | crates/shirabe/src/command/package_discovery_trait.rs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index 501ae5d..f9aa811 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -5,7 +5,7 @@ use std::any::Any; use anyhow::Result; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::composer::pcre::preg::{CaptureKey, Preg}; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; use shirabe_php_shim::{ @@ -354,26 +354,36 @@ pub trait PackageDiscoveryTrait { } } - if let Some(m) = Preg::is_match_strict_groups( + let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); + if Preg::is_match_strict_groups3( r"{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}", &selection, - ) { - if let Some(v) = m.get("version") { + Some(&mut m), + ) + .unwrap_or(false) + { + if let Some(v) = + m.get(&CaptureKey::ByName("version".to_string())).cloned() + { // parsing `acme/example ~2.3` // validate version constraint // TODO(phase-b): parse_constraints returns Result - let _ = version_parser_clone.parse_constraints(v); + let _ = version_parser_clone.parse_constraints(&v); return PhpMixed::String(format!( "{} {}", - m.get("name").cloned().unwrap_or_default(), + m.get(&CaptureKey::ByName("name".to_string())) + .cloned() + .unwrap_or_default(), v, )); } // parsing `acme/example` return PhpMixed::String( - m.get("name").cloned().unwrap_or_default(), + m.get(&CaptureKey::ByName("name".to_string())) + .cloned() + .unwrap_or_default(), ); } @@ -537,7 +547,9 @@ pub trait PackageDiscoveryTrait { } // Check whether the package requirements were the problem - let is_ignore_all = (platform_requirement_filter.as_ref().as_any() as &dyn Any) + let is_ignore_all = platform_requirement_filter + .as_ref() + .as_any() .downcast_ref::<IgnoreAllPlatformRequirementFilter>() .is_some(); if !is_ignore_all { @@ -861,7 +873,8 @@ pub trait PackageDiscoveryTrait { let mut platform_pkg_version = platform_pkg.get_pretty_version().to_string(); let platform_extra = platform_pkg.get_extra(); let has_config_platform = platform_extra.contains_key("config.platform"); - let is_complete = (platform_pkg.as_any() as &dyn Any) + let is_complete = platform_pkg + .as_any() .downcast_ref::<dyn CompletePackageInterface>() .is_some(); if has_config_platform && is_complete { |
