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/repository/composer_repository.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/repository') diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 59e1d520..b2476e1e 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -39,7 +39,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_metadata_minifier::MetadataMinifier; use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, + CmpOp, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, UnexpectedValueException, extension_loaded, hash, http_build_query, json_decode, parse_url_all, php_regex, realpath, strtolower, strtr, urlencode, var_export, }; @@ -2110,7 +2110,7 @@ impl ComposerRepository { } if let Some(c) = constraint - && !CompilingMatcher::r#match(c, SimpleConstraint::OP_EQ, version.clone()) + && !CompilingMatcher::r#match(c, CmpOp::Eq, version.clone()) { continue; } -- cgit v1.3.1-4-g156e