@param string $versionString

@throws InvalidVersionStringException

@return Version
188916
public static function fromString(string $versionString) : Version
    {
        if (!preg_match(
            '#^'
            . '(v|release\-)?'
            . '(?P<core>(?:[0-9]|[1-9][0-9]+)(?:\.(?:[0-9]|[1-9][0-9]+)){2})'
            . '(?:\-(?P<preRelease>[0-9A-Za-z\-\.]+))?'
            . '(?:\+(?P<build>[0-9A-Za-z\-\.]+))?'
            . '$#',
            $versionString,
            $parts
        )) {
            throw InvalidVersionStringException::forVersionString($versionString);
        }

        [$major, $minor, $patch] = explode('.', $parts['core']);
        $preRelease = !empty($parts['preRelease']) ? PreRelease::fromIdentifiersString($parts['preRelease']) : new NoPreRelease();
        $build = !empty($parts['build']) ? Build::fromIdentifiersString($parts['build']) : new NoBuild();

        return static::fromParts((int) $major, (int) $minor, (int) $patch, $preRelease, $build);
    }
311387
protected static function extractVersion(string $version, string $expression): ?string
    {
        if (preg_match($expression, $version, $result)) {
            return Arr::first($result);
        }

        return null;
    }
849190
public function setVersion(string $version)
    {
        if (Validation::isValidVersionRegex($version)) {
            $this->version = $version;
        } else {
            throw new CustomException('Malformed version');
        }
    }
433547
protected function get_full_version_string($versionString) {
		if(strlen($versionString)) {
			$bits = $this->parse_version_string($versionString);
			
			$fullVersion = $bits['version_major'] .'.'. $bits['version_minor'] .'.'.
					$bits['version_maintenance'];
			if(strlen($bits['version_suffix'])) {
				$fullVersion .= '-'. $bits['version_suffix'];
			}
		}
		else {
			$this->error_handler(__METHOD__ .": no version string given");
		}
		
		return($fullVersion);
	}
97026
public static function getVersionForNumber(int $versionNumber) : self
    {
        if ($versionNumber < 1 || $versionNumber > 40) {
            throw new InvalidArgumentException('Version number must be between 1 and 40');
        }

        return self::versions()[$versionNumber - 1];
    }
886696
protected function update_database_version($newVersionString) {
		$versionInfo = $this->parse_version_string($newVersionString);
		$sql = "UPDATE ". $this->dbTable ." SET version_string=:vStr WHERE project_name=:pName";
		$params = array(
			'vStr'	=> $versionInfo['version_string'],
			'pName'	=> $this->projectName
		);
		
		
		$updateRes = $this->db->run_update($sql, $params);
		if($updateRes == 1) {
			$retval = $updateRes;
		}
		else {
			$this->error_handler(__METHOD__ .": invalid result (". $updateRes .")	");
		}
		
		//okay, now check that the version string matches the updated bits.
		if(!$this->check_database_version($versionInfo)) {
			$this->error_handler(__METHOD__ .": database version information is invalid: (". $versionInfo .")");
		}
		
		return($retval);
		
	}
576417
public function detectVersion(string $useragent): VersionInterface
    {
        $safariHelper = new SafariHelper();

        $doMatch = preg_match('/(?:Version|Safari)\/([\d\.]+)/', $useragent, $matches);

        if ($doMatch) {
            return (new VersionFactory())->set($safariHelper->mapSafariVersion($matches[1]));
        }

        return (new VersionFactory())->set('0');
    }
956468
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerContactInfoVersionQuery::create()
            ->filterByDealerContactInfo($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
1223073
public function detectVersion(string $useragent): VersionInterface
    {
        $doMatch = preg_match('/Friendica \'[^\']*\' (\d+[\d\.\_\-\+abcdehlprstv]*).*/', $useragent, $matches);

        if (!$doMatch) {
            return new Version('0');
        }

        return (new VersionFactory())->set($matches[1]);
    }
619677
public function getVersionString() {
        if ($this->versionString === null) {
            if (!$this->isConnected())
                $this->connect();
            $this->versionString = pg_version($this->hConnection)['server'];
        }
        return $this->versionString;
    }
1188409
public static function fromString(string $version)
    {
        $version = trim($version);

        /*
         * No version provided?
         * Nothing to do
         */
        if (empty($version)) {
            return null;
        }

        $matches = [];
        $pattern = '/^(\d+)\.(\d+)\.(\d+)$/'; // e.g. "1.0.2"
        $matched = preg_match($pattern, $version, $matches);

        /*
         * Incorrect version?
         * Nothing to do
         */
        if (0 === $matched || false === $matched) {
            return null;
        }

        $majorPart = (int)$matches[1];
        $minorPart = (int)$matches[2];
        $patchPart = (int)$matches[3];

        return new static($majorPart, $minorPart, $patchPart);
    }
621501
private static @CheckForNull VersionNumber toVersion(@CheckForNull String versionString) {
        if (versionString == null) {
            return null;
        }

        try {
            return new VersionNumber(versionString);
        } catch (NumberFormatException e) {
            try {
                // for non-released version of Jenkins, this looks like "1.345 (private-foobar), so try to approximate.
                int idx = versionString.indexOf(' ');
                if (idx > 0) {
                    return new VersionNumber(versionString.substring(0,idx));
                }
            } catch (NumberFormatException ignored) {
                // fall through
            }

            // totally unparseable
            return null;
        } catch (IllegalArgumentException e) {
            // totally unparseable
            return null;
        }
    }
1363832
public static Version stringToVersion(String str) {
        if (str == null || str.isEmpty() || str.equals("0")) {
            return Version.emptyVersion;
        }

        if (str.equals("1") || str.equals("1.0") || str.equals("1.0.0"))
            return VERSION_1_0;

        return new Version(str);
    }
1228005
func (meta debMetadata) VersionString() string {
	vsn := meta.Version
	if meta.Env.Buildnum != "" {
		vsn += "+build" + meta.Env.Buildnum
	}
	if meta.Distro != "" {
		vsn += "+" + meta.Distro
	}
	return vsn
}
1179412
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerFolderVersionQuery::create()
            ->filterByDealerFolder($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
318415
protected function formatDate($dateString)
    {
        try {
            // We have to handle timestamps a little differently
            if (is_numeric($dateString) && (int) $dateString == $dateString) {
                $date = DateTime::createFromFormat('U', (int) $dateString, new DateTimeZone('UTC'));
            } else {
                $date = new DateTime($dateString, new DateTimeZone('UTC'));
            }

            return $date->format(DateTime::W3C);
        } catch (\Exception $e) {
            throw new InvalidArgumentException("Malformed last modified date: {$dateString}", 0, $e);
        }
    }
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;
    }