From da0d38a8e16ebefd59ef5291b5788e6238cc78ba Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 8 Aug 2026 03:04:27 +0900 Subject: refactor(semver): replace Constraint's OP_*/STR_OP_* with CmpOp PHP's version_compare takes its operator as a string, so the shim's port did too, and Constraint carried two families of operator constants plus translation tables to convert between the string form and its own int codes. Five copies of those tables had accumulated across Constraint, CompilingMatcher and the plugin value bridge. version_compare now takes a CmpOp, which makes an invalid operator unrepresentable and removes the tables' reason to exist. Constraint stores a CmpOp and keeps only the string parsing its constructor needs; getOperator, compile and CompilingMatcher::match speak CmpOp as well. PHP's OP_* numbering stays observable: a plugin reads the raw integer off the Constraint object over RPC, so get_operator_constant and its new inverse hold that 0..5 mapping. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/dependency_resolver/pool_builder.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/src/dependency_resolver/pool_builder.rs') diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index 137a36ba..35699a90 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -21,7 +21,7 @@ use crate::repository::RootPackageRepository; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ - LogicException, PhpMixed, array_flip_strings, array_map, in_array_strict, microtime, + CmpOp, LogicException, PhpMixed, array_flip_strings, array_map, in_array_strict, microtime, number_format, round, strpos, }; use shirabe_semver::CompilingMatcher; @@ -29,7 +29,6 @@ use shirabe_semver::Intervals; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MatchAllConstraint; use shirabe_semver::constraint::MultiConstraint; -use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct PoolBuilder { @@ -289,7 +288,7 @@ impl PoolBuilder { for (_idx, package_or_alias) in &package_and_aliases { if CompilingMatcher::r#match( &constraint, - SimpleConstraint::OP_EQ, + CmpOp::Eq, package_or_alias.get_version(), ) { found = true; -- cgit v1.3.1-4-g156e