=%1$s-stable', $currentParts[0] + ($isPreRelease ? 0 : 1))); $minorCandidates = SemVer::satisfiedBy($latest, sprintf('~%1$s.%2$s', $currentParts[0], $currentParts[1] + 1)); $patchCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s <%1$s.%3$s', $currentParts[0], $currentParts[1], $currentParts[2] + 1)); $hasMajor = !empty($majorCandidates); $hasMinor = !empty($minorCandidates); $hasPatch = !empty($patchCandidates); $hasMultiMajor = count($majorCandidates) > 1; if ($isPreRelease) { $stableVersions = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s-stable', $currentParts[0], $currentParts[1], $currentParts[2])); // git releases are never interested in a stable version :P $hasStable = !empty($stableVersions) && !$isGitRelease; // no warning if no major release available, orange warning if you are on unreleased code $class = $hasStable ? 'update2' : 'uptodate'; } else if ($hasPatch || $hasMultiMajor) { // current patch or more than 1 major behind $class = 'outdated'; } else if ($hasMinor) { // green warning for feature update $class = 'update'; } else if ($hasMajor) { // orange warning for 1 major beind $class = 'update2'; } else { $class = 'uptodate'; } $latest = SemVer::rsort($latest); $highestVersion = $latest[0]; $data = (object) array( 'link' => $link, 'latest' => $highestVersion, 'current' => $current, 'hasPatch' => $hasPatch, 'hasMinor' => $hasMinor, 'hasMajor' => $hasMajor, 'isPreRelease' => $isPreRelease, 'hasMultiMajor' => $hasMultiMajor, ); $result = sprintf('', json_encode($data)) . "
"; return $result; } }