Refactor CheckUpdateResult logic to simplify version comparison

This commit is contained in:
crazywhalecc
2026-03-05 11:11:02 +08:00
parent 5298ee4f97
commit abdaaab6e6
5 changed files with 8 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ class FileList implements DownloadTypeInterface, CheckUpdateInterface
return new CheckUpdateResult(
old: $old_version,
new: $version,
needUpdate: $old_version === null || version_compare($version, $old_version, '>'),
needUpdate: $old_version === null || $version !== $old_version,
);
}

View File

@@ -120,7 +120,7 @@ class Git implements DownloadTypeInterface, CheckUpdateInterface
return new CheckUpdateResult(
old: $old_version,
new: $version,
needUpdate: $old_version === null || version_compare($version, $old_version, '>'),
needUpdate: $old_version === null || $version !== $old_version,
);
}
throw new DownloaderException("No matching branch found for regex {$config['regex']}.");

View File

@@ -22,7 +22,7 @@ class PECL implements DownloadTypeInterface, CheckUpdateInterface
return new CheckUpdateResult(
old: $old_version,
new: $version,
needUpdate: $old_version === null || version_compare($version, $old_version, '>'),
needUpdate: $old_version === null || $version !== $old_version,
);
}

View File

@@ -40,7 +40,7 @@ class PIE implements DownloadTypeInterface, CheckUpdateInterface
return new CheckUpdateResult(
old: $old_version,
new: $new_version,
needUpdate: $old_version === null || version_compare($new_version, $old_version, '>'),
needUpdate: $old_version === null || $new_version !== $old_version,
);
}