Check if current version of the theme is higher than the one available at WP.org.

@param string $slug Theme slug.
@param string $version Theme current version.

@return bool|string
555284
protected function is_theme_version_valid( $slug, $version ) {
		// Get Theme Info.
		$theme_info = themes_api( 'theme_information', array( 'slug' => $slug ) );

		// Return empty string for themes not on WP.org.
		if ( is_wp_error( $theme_info ) ) {
			return '';
		}

		// Compare theme version info.
		return ! version_compare( $version, $theme_info->version, '>' );

	}
1304998
public static function getVersionCompatible($version)
    {
        // {suffix:weight}
        $suffixes = [
            'dev' => 1, // composer suffix
            'patch' => 2,
            'alpha' => 3,
            'beta' => 4,
            'stable' => 5, // is not a real suffix. use it if suffix is not exists
            'rc' => 6,
        ];

        $reg = '/^v?(?<version>\d+\.\d+\.\d+)(?:-(?<suffix>dev|patch|alpha|beta|rc)(?<suffix_version>\d+)?)?$/i';
        if (!preg_match($reg, $version, $match)) {
            return false;
        }

        // suffix version
        if (isset($match['suffix'])) {
            $suffix = $suffixes[strtolower($match['suffix'])].'.';
            $suffix .= isset($match['suffix_version']) ? (int) $match['suffix_version'] : 1;
        } else {
            $suffix = $suffixes['stable'].'.0';
        }

        return $match['version'].'.'.$suffix;
    }
1267033
public function setHttpVersion($version)
    {
        // Version validation pattern
        $pattern = '~^1\.[01]$~';

        if (! preg_match($pattern, $version))
            return false;

        $this->httpVersion = $version;
        return true;
    }
437788
public static function compare($version)
    {
        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
        $version        = str_replace(' ', '', $version);

        return version_compare($version, $currentVersion);
    }
444196
public static function isVersion($version){
        $currentVersion = Craft::$app->getVersion();
        $version = explode('.', $version);
        $currentVersion = explode('.', $currentVersion);
        $isVersion = true;
        foreach($version as $key => $value){
            if ((int)$currentVersion[$key] < $version[$key]){ 
                $isVersion = false;
            }
        }
        return $isVersion;
    }
1302383
public static function compare(Version $version1, Version $version2)
    {
        if ($version1->toString() == $version2->toString()) {
            return 0;
        }

        $v1 = $version1->getVersionArray();
        $v2 = $version2->getVersionArray();

        if (count($v1) > count($v2)) {
            $v2 = array_pad($v2, count($v1), 0);
        } elseif (count($v1) < count($v2)) {
            $v1 = array_pad($v1, count($v2), 0);
        }

        // version comparison
        foreach ($v1 as $k => $v) {
            if ($v == $v2[$k]) {
                continue;
            }
            if ($v < $v2[$k]) {
                return -1;
            } else {
                return 1;
            }
        }

        // stability comparison
        $s1 = $version1->getStabilityVersion();
        $s2 = $version2->getStabilityVersion();
        if (count($s1) > count($s2)) {
            $s2 = array_pad($s2, count($s1), '');
        } elseif (count($s1) < count($s2)) {
            $s1 = array_pad($s1, count($s2), '');
        }

        foreach ($s1 as $k => $v) {
            if ($v == '*' || $s2[$k] == '*') {
                return 0;
            }
            if ($v === $s2[$k]) {
                continue;
            }
            if ($v === '') {
                if (!is_numeric($s2[$k])) {
                    return 1;
                } else {
                    $v = '0';
                }
            } elseif ($s2[$k] === '') {
                if (!is_numeric($v)) {
                    return -1;
                } else {
                    $s2[$k] = '0';
                }
            }
            if (is_numeric($v)) {
                if (is_numeric($s2[$k])) {
                    $v1 = intval($v);
                    $v2 = intval($s2[$k]);
                    if ($v1 == $v2) {
                        continue;
                    }
                    if ($v1 < $v2) {
                        return -1;
                    }
                    return 1;
                } else {
                    return -1;
                }
            } elseif (is_numeric($s2[$k])) {
                return -1;
            } else {
                if ($v == 'dev' || $v == 'pre') {
                    $v = 'aaaaaaaaaa';
                }
                $v2 = $s2[$k];
                if ($v2 == 'dev' || $v2 == 'pre') {
                    $v2 = 'aaaaaaaaaa';
                }
                $r = strcmp($v, $v2);
                if ($r > 0) {
                    return 1;
                } elseif ($r < 0) {
                    return -1;
                }
            }
        }

        $sv1 = $version1->getSecondaryVersion();
        $sv2 = $version2->getSecondaryVersion();
        if (($sv1 instanceof Version) || ($sv2 instanceof Version)) {
            if (($sv1 instanceof Version) && ($sv2 instanceof Version)) {
                return self::compare($sv1, $sv2);
            }
            else if ($sv1 instanceof Version) {
                return 1;
            }
            else if ($sv2 instanceof Version) {
                return -1;
            }
        }
        return 0;
    }
448363
public static function laravelVersionIs($operator, $version, $laravel = null)
    {
        if (is_null($laravel)) {
            $laravel = app()->version();
        }

        $laravel = strtok($laravel, ' ');

        return version_compare($laravel, $version, $operator);
    }
1014317
public function isVersion($phpVersion)
	{
		$compare = version_compare($this->getVersion(), $phpVersion);
		return ($compare === 1 || $compare === 0) ? true : false;
	}
1257545
private static function fetchProtocolVersion(string $version): string
    {
        $v = substr($version, 5);

        if ($v === '2.0') {
            return '2';
        }

        // Fallback for values outside of valid protocol versions
        if (!in_array($v, static::$allowedVersions, true)) {
            return '1.1';
        }

        return $v;
    }
699254
public function match(Version $version)
    {
        $versionStabilityIndex = array_search($version->getStability(), Version::$stabilities);
        $constraintStabilityIndex = array_search($this->stability, Version::$stabilities);

        if ($this->compare($versionStabilityIndex, $constraintStabilityIndex) !== 0) {
            return false;
        }

        $numericValues = $version->numeric();
        $comparisons = array();

        foreach ($this->version as $i => $value) {
            $comparisons[$i] = $this->compare($numericValues[$i], $value);
        }

        switch ($this->operator) {
            case '=': case '==':
                // all parts must be equal:
                return array_filter($comparisons) === array();
                break;
            case '!': case '!=':
                // any part must be unequal:
                return array_filter($comparisons) !== array();
                break;
            case '>=':
            case '<=':
            case '>':
            case '<':
                // the first mismatch is the tie breaker
                $mismatches = array_filter($comparisons);
                if (!count($mismatches)) {
                    // if no mismatches, only ok if equality operator
                    return in_array($this->operator, array('<=', '>='));
                } else {
                    $first = array_shift($mismatches);
                    return
                           ($this->operator === '<'  && $first < 0)
                        || ($this->operator === '<=' && $first < 0)
                        || ($this->operator === '>'  && $first > 0)
                        || ($this->operator === '>=' && $first > 0)
                    ;
                }
        }

        throw new \UnexpectedValueException("An unknown edge case was encountered. Is the constraint valid?");
    }
363344
public function withProtocolVersion($version)
    {
        $response = $this->_withProtocolVersion($version);
        
        if ($response->status instanceof GlobalResponseStatus) {
            $response->status = $response->status->withProtocolVersion($response->getProtocolVersion());
        }
        
        return $response;
    }
931656
protected function getVersion($version)
    {
        if (!$this->{$version.'Version'}) {
            $revisioned = get_class($this->revisioned);

            $revision = new $revisioned();
            $revision->setRawAttributes($this->{$version});

            $this->{$version.'Version'} = $revision;
        }

        return $this->{$version.'Version'};
    }
480219
protected function assertProtocolVersion($version)
    {
        if (!is_string($version) && !is_numeric($version)) {
            throw new \InvalidArgumentException("HTTP version must be a string or float");
        }
        
        if ($version != '' && $version !== "1.0" && $version !== "1.1" && $version !== "2") {
            throw new \InvalidArgumentException("Invalid HTTP protocol version '$version'");
        }
    }
563535
public function version($version = null)
    {
        if (!$version) {
            $versionParts = explode('.', \Peridot\Console\Version::NUMBER);
            $versionParts[count($versionParts)-1]++;
            $version = implode('.', $versionParts);
        }
        $versionFile = __DIR__ . '/src/Console/Version.php';
        $this->taskReplaceInFile($versionFile)
            ->from('NUMBER = "' . \Peridot\Console\Version::NUMBER . '"')
            ->to('NUMBER = "' . $version . '"')
            ->run();

        return $version;
    }
102746
protected function download($version, $slug)
    {
        $archive = $this->directory.'chromedriver.zip';

        $url = sprintf(static::$downloadUrl, $version, $slug);

        file_put_contents($archive, fopen($url, 'r'));

        return $archive;
    }
1345430
protected function mustGreaterEqualThan(Version $version)
    {
        if ($version->getFloatMajor() > $this->getFloatMajor())
            return false;

        else if ($version->getFloatMajor() == $this->getFloatMajor())
        {
            if (is_null($version->minor))
                return true;

            if ($version->getFloatMinor() > $this->getFloatMinor())
                return false;

            else if ($version->getFloatMinor() == $this->getFloatMinor())
            {
                if (is_null($version->path))
                    return true;

                if ($version->getFloatPath() > $this->getFloatPath())
                    return false;

                else if ($version->getFloatPath() == $this->getFloatPath())
                    return true;
            }
        }

        return true;
    }
385027
public function can_upgrade($type, $version) {
        if ($type == 'offline' && $version >= 2011112900) {
            return true;
        }
        foreach ($this->submissionplugins as $plugin) {
            if ($plugin->can_upgrade($type, $version)) {
                return true;
            }
        }
        foreach ($this->feedbackplugins as $plugin) {
            if ($plugin->can_upgrade($type, $version)) {
                return true;
            }
        }
        return false;
    }