Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions htdocs/kernel/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,29 @@ public function getStatus()
* @param string $operator
* @return boolean The function will return true if the relationship is the one specified by the operator, false otherwise.
*/
public function versionCompare($version1 = '', $version2 = '', $operator = '<')
public function versionCompare($version1 = '', $version2 = '', $operator = '<'): bool
{
$version1 = strtolower($version1);
$version2 = strtolower($version2);
if (false !== strpos($version2, '-stable')) {
$version2 = substr($version2, 0, strpos($version2, '-stable'));
}
if (false !== strpos($version1, '-stable')) {
$version1 = substr($version1, 0, strpos($version1, '-stable'));
$normalize = static function ($ver): string {
$ver = strtolower(trim((string)$ver));
if (($pos = strpos($ver, '-')) !== false) {
$ver = substr($ver, 0, $pos);
}
return trim($ver);
};

$n1 = $normalize($version1);
$n2 = $normalize($version2);

$op = (string)$operator;
$allowed = ['<', '<=', '>', '>=', '==', '!=', '<>'];
if (!in_array($op, $allowed, true)) {
$op = '<';
}
return version_compare($version1, $version2, $operator);

return (bool)version_compare($n1, $n2, $op);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit cast to (bool) on line 215 is unnecessary. The version_compare() function already returns a boolean when an operator is provided, so the cast is redundant.

Suggested change
return (bool)version_compare($n1, $n2, $op);
return version_compare($n1, $n2, $op);

Copilot uses AI. Check for mistakes.
}


/**
* Get a link to the modules main page
*
Expand Down