aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-23 23:14:52 +0900
committernsfisis <nsfisis@gmail.com>2026-05-23 23:15:14 +0900
commitdbdecaf5a1c54a876b7ee0153d58dd39b1080f97 (patch)
treef13f2ced03c803dcbc42a5672458b3cb19ff0f30 /crates/shirabe/src/plugin
parentf5b987a00712211b7ce56300851182bda904e97b (diff)
downloadphp-shirabe-dbdecaf5a1c54a876b7ee0153d58dd39b1080f97.tar.gz
php-shirabe-dbdecaf5a1c54a876b7ee0153d58dd39b1080f97.tar.zst
php-shirabe-dbdecaf5a1c54a876b7ee0153d58dd39b1080f97.zip
refactor(semver): change ConstraintInterface to a closed enum
Replace the dyn ConstraintInterface trait objects with an AnyConstraint enum closing over its four implementors (Simple, Multi, MatchAll, MatchNone), mirroring the earlier Rule enum conversion. Rename constraint.rs to simple_constraint.rs to match the renamed Constraint type. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/plugin')
-rw-r--r--crates/shirabe/src/plugin/plugin_manager.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs
index 26e6296..77ac577 100644
--- a/crates/shirabe/src/plugin/plugin_manager.rs
+++ b/crates/shirabe/src/plugin/plugin_manager.rs
@@ -13,7 +13,8 @@ use shirabe_php_shim::{
is_array, is_string, ksort, preg_quote, str_replace, strrpos, strtr, substr, trigger_error,
trim, var_export, var_export_str, version_compare,
};
-use shirabe_semver::constraint::Constraint;
+use shirabe_semver::constraint::AnyConstraint;
+use shirabe_semver::constraint::SimpleConstraint;
use crate::composer::PartialComposerHandle;
use crate::composer::{ComposerHandle, ComposerWeakHandle};
@@ -227,9 +228,7 @@ impl PluginManager {
if package.get_type() == "composer-plugin" {
let requires_map = package.get_requires();
- let mut requires_composer: Option<
- &dyn shirabe_semver::constraint::ConstraintInterface,
- > = None;
+ let mut requires_composer: Option<&shirabe_semver::constraint::AnyConstraint> = None;
for (_k, link) in &requires_map {
if "composer-plugin-api" == link.get_target() {
requires_composer = Some(link.get_constraint());
@@ -248,15 +247,17 @@ impl PluginManager {
};
let current_plugin_api_version = self.get_plugin_api_version();
- let current_plugin_api_constraint = Constraint::new(
- "==",
+ let current_plugin_api_constraint = SimpleConstraint::new(
+ "==".to_string(),
self.version_parser
- .normalize(&current_plugin_api_version, None)?,
+ .normalize(&current_plugin_api_version, None)?
+ .to_string(),
+ None,
);
if requires_composer.get_pretty_string() == self.get_plugin_api_version() {
self.io.write_error(&format!("<warning>The \"{}\" plugin requires composer-plugin-api {}, this *WILL* break in the future and it should be fixed ASAP (require ^{} instead for example).</warning>", package.get_name(), self.get_plugin_api_version(), self.get_plugin_api_version()));
- } else if !requires_composer.matches(&current_plugin_api_constraint) {
+ } else if !requires_composer.matches(&current_plugin_api_constraint.into()) {
self.io.write_error(&format!("<warning>The \"{}\" plugin {}was skipped because it requires a Plugin API version (\"{}\") that does not match your Composer installation (\"{}\"). You may need to run composer update with the \"--no-plugins\" option.</warning>",
package.get_name(),
if is_global_plugin || self.running_in_global_dir { "(installed globally) " } else { "" },