aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/diagnose_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-08 03:04:27 +0900
committernsfisis <nsfisis@gmail.com>2026-08-08 03:04:27 +0900
commitda0d38a8e16ebefd59ef5291b5788e6238cc78ba (patch)
treec6a4cb9f2444beeb84b2d30133053867acb46741 /crates/shirabe/src/command/diagnose_command.rs
parentc0879ab4a02b257cb0bd416dbdfa07784c8e3809 (diff)
downloadphp-shirabe-da0d38a8e16ebefd59ef5291b5788e6238cc78ba.tar.gz
php-shirabe-da0d38a8e16ebefd59ef5291b5788e6238cc78ba.tar.zst
php-shirabe-da0d38a8e16ebefd59ef5291b5788e6238cc78ba.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/diagnose_command.rs')
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index 65240e51..72b58dea 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -39,10 +39,10 @@ use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_external_packages::symfony::process::ExecutableFinder;
use shirabe_php_shim::{
- InvalidArgumentException, PHP_EOL, PhpMixed, disk_free_space, file_exists, filter_var_boolean,
- get_class_err, hash, impl_php_class, implode, is_array, is_string, php_regex, rtrim,
- str_contains, str_replace, str_starts_with, strpos, strstr, strstr3, strtolower, trim,
- version_compare,
+ CmpOp, InvalidArgumentException, PHP_EOL, PhpMixed, disk_free_space, file_exists,
+ filter_var_boolean, get_class_err, hash, impl_php_class, implode, is_array, is_string,
+ php_regex, rtrim, str_contains, str_replace, str_starts_with, strpos, strstr, strstr3,
+ strtolower, trim, version_compare,
};
#[derive(Debug)]
@@ -153,7 +153,7 @@ impl DiagnoseCommand {
None => return "<comment>No git process found</>".to_string(),
};
- if version_compare("2.24.0", &git_version, ">") {
+ if version_compare("2.24.0", &git_version, CmpOp::Gt) {
return format!(
"<warning>Your git version ({}) is too old and possibly will cause issues. Please upgrade to git 2.24 or above</>",
git_version
@@ -889,9 +889,9 @@ impl DiagnoseCommand {
}
if diagnostics.has_php_windows_version_build
- && (version_compare(&diagnostics.php_version, "7.2.23", "<")
- || (version_compare(&diagnostics.php_version, "7.3.0", ">=")
- && version_compare(&diagnostics.php_version, "7.3.10", "<")))
+ && (version_compare(&diagnostics.php_version, "7.2.23", CmpOp::Lt)
+ || (version_compare(&diagnostics.php_version, "7.3.0", CmpOp::Ge)
+ && version_compare(&diagnostics.php_version, "7.3.10", CmpOp::Lt)))
{
warnings.insert(
"onedrive".to_string(),