diff --git a/src/utils/VersionString.php b/src/utils/VersionString.php index 59a4deddad..1dd666c9f1 100644 --- a/src/utils/VersionString.php +++ b/src/utils/VersionString.php @@ -117,18 +117,16 @@ class VersionString{ if($diff){ return $tNumber - $number; } - if($number > $tNumber){ - return -1; //Target is older - }elseif($number < $tNumber){ - return 1; //Target is newer - }elseif($target->isDev() and !$this->isDev()){ - return -1; //Dev builds of the same version are always considered older than a release - }elseif($target->getBuild() > $this->getBuild()){ - return 1; - }elseif($target->getBuild() < $this->getBuild()){ - return -1; - }else{ - return 0; //Same version + + if(($result = $tNumber <=> $number) !== 0){ + return $result; } + if($target->isDev() !== $this->isDev()){ + return $this->isDev() ? 1 : -1; //Dev builds of the same version are always considered older than a release + } + if(($target->getSuffix() === "") !== ($this->suffix === "")){ + return $this->suffix !== "" ? 1 : -1; //alpha/beta/whatever releases are always considered older than a non-suffixed version + } + return $target->getBuild() <=> $this->getBuild(); } }