Retrieve server version in PHP style

@return string
976029
public function getServerVersion()
    {
        $this->_connect();
        $server_info = db2_server_info($this->_connection);
        if ($server_info !== false) {
            $version = $server_info->DBMS_VER;
            if ($this->_isI5) {
                $version = (int) substr($version, 0, 2) . '.' . (int) substr($version, 2, 2) . '.' . (int) substr($version, 4);
            }
            return $version;
        } else {
            return null;
        }
    }
1154997
protected function _getVersion()
    {
        if (!isset($this->_version)) {
            //if table doesn't exists
                $this->_db->execute(<<<EOF
CREATE TABLE IF NOT EXISTS `#__migrator_versions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `component` varchar(255) NOT NULL,
  `version` text NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `component` (`component`)
)ENGINE=InnoDB;
EOF
                );
            $this->_version = $this->getService('repos:migrator.version')
                    ->findOrAddNew(array('component' => $this->_component));
        }

        return $this->_version;
    }
463366
public static function getSolrMajorVersion() {
        $type = static::getSolrType();
        $version = FALSE;
        if ($type) {
            list(, $version) = explode(":", $type);
            if (preg_match('/^(\d)\./', $version, $matches)) {
                $version = $matches[1];
            }
            else {
                $version = '4';
            }
            // Platform support 3,4 and 6 atm. We only support 4 and 6.
            if ($version === '3') {
                $version = '4';
            }
        }
        return $version;
    }
1372629
public function getClientVersion()
    {
        $this->_connect();
        try {
            $version = $this->_connection->getAttribute(PDO::ATTR_CLIENT_VERSION);
            $requiredVersion = Config::getInstance()->General['minimum_mssql_client_version'];
            if (version_compare($version['DriverVer'], $requiredVersion) === -1) {
                throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MSSQL', $version['DriverVer'], $requiredVersion)));
            } else {
                return $version['DriverVer'];
            }
        } catch (PDOException $e) {
            // In case of the driver doesn't support getting attributes
        }

        return null;
    }
547689
public function getVersionsToSync()
    {
        $versionsToSync      = [ ];
        $remote              = $this->client($this->setting('connection'));
        $currentVersions     = $this->project->getRefs();
        $allowedVersionRange = new expression($this->setting('sync.constraints.versions'));
        $tags                = $remote->getTags($this->setting('repository'), $this->setting('owner'));
        $skipPatch           = $this->setting('sync.constraints.skip_patch_versions', false);
        $skipMinor           = $this->setting('sync.constraints.skip_minor_versions', false);
        $skipPatch           = $skipMinor === true ? true : $skipPatch; // if we skip minors, we automaticly skip patches as well

        $this->fire('versions.start', [ $tags ]);

        foreach ( $tags as $tag => $sha )
        {
            try
            {
                $version = new version($tag);
            }
            catch (SemVerException $e)
            {
                continue;
            }

            // Check all version constraints
            if ( $version->satisfies($allowedVersionRange) === false || in_array($version->getVersion(), $currentVersions, true) )
            {
                continue;
            }
            if ( $skipPatch === true && $version->getPatch() !== 0 )
            {
                continue;
            }
            if ( $skipMinor === true && $version->getMinor() !== 0 )
            {
                continue;
            }

            // This version is inside constraints, add it
            $versionsToSync[] = $version;
        }

        $this->fire('versions.finish', [ $versionsToSync ]);
        return $versionsToSync;
    }
942721
protected function _getMySqlServerInfo()
    {
        $aResult = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC)->getRow("SHOW VARIABLES LIKE 'version'");

        return $aResult['Value'];
    }
99315
public function minPHPVersion()
    {
        if (null === $this->min_php) {
            $this->min_php = $this->remote->getMinPHPVersion();
        }
        return $this->min_php;
    }
135381
public function getDisplayVersion()
    {
        if ($this->isDevVersion()) {
            return t(/*i18n: %s is a version*/'%s development series', substr($this->version, strlen(static::DEV_PREFIX)));
        } else {
            return $this->version;
        }
    }
51047
public function get_server_info() {
        $version = $this->mysqli->server_info;
        $matches = null;
        if (preg_match('/^5\.5\.5-(10\..+)-MariaDB/i', $version, $matches)) {
            // Looks like MariaDB decided to use these weird version numbers for better BC with MySQL...
            $version = $matches[1];
        }
        return array('description'=>$this->mysqli->server_info, 'version'=>$version);
    }
1013620
public function version()
    {
        $this->sendCommand('version');
        $res = fgets($this->conn, 4096);
        $this->checkForError($res);

        return trim($res);
    }
996248
public function getClientVersion()
    {
        $this->_connect();
        try {
            $version = $this->_connection->getAttribute(PDO::ATTR_CLIENT_VERSION);
            $matches = null;
            if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
                return $matches[1];
            }
        } catch (PDOException $e) {
            // In case of the driver doesn't support getting attributes
        }
        return null;
    }
890916
protected function getVersion()
    {
        // Get version from tag
        $cmd = new Command('git');
        $cmd = $cmd->arg('tag')
            ->execute();
        $output = explode(PHP_EOL, trim($cmd->getOutput()));
        $currentVersion = '0.0.0';
        foreach ($output as $tag) {
            if (preg_match(SemanticVersion::REGEX, $tag)) {
                if (version_compare($currentVersion, $tag, '<')) {
                    $currentVersion = $tag;
                }
            }
        }
        return new SemanticVersion($currentVersion);
    }
1129859
final protected function getVersion() {
        if(CB_VERSION!='@@VERSION@@') {
            return CB_VERSION.' '.CB_BUILD_DATE;
        }
        
        // Tries to obtain version number from composer.lock if it exists
        $composerLockPath=BASE_PATH.'/composer.lock';
        if(file_exists($composerLockPath)) {
            $cache=SS_Cache::factory('CodeBank_Version');
            $cacheKey=filemtime($composerLockPath);
            $version=$cache->load($cacheKey);
            if($version) {
                $version=$version;
            }else {
                $version='';
            }
            
            if(!$version && $jsonData=file_get_contents($composerLockPath)) {
                $lockData=json_decode($jsonData);
                if($lockData && isset($lockData->packages)) {
                    foreach ($lockData->packages as $package) {
                        if($package->name=='undefinedoffset/silverstripe-codebank' && isset($package->version)) {
                            $version=$package->version;
                            break;
                        }
                    }
                    
                    $cache->save($version, $cacheKey);
                }
            }
        }
        
        if(!empty($version)) {
            return $version;
        }
        
        return _t('CodeBank.DEVELOPMENT_BUILD', '_Development Build');
    }
362860
public function getProtocolVersion()
    {
        $version = null;
        if (isset($this->server['SERVER_PROTOCOL'])) {
            $protocol = $this->server['SERVER_PROTOCOL'];
            list(,$version) = explode("/", $protocol);
        }

        return $version;
    }
151020
private static function getPhpVersionInfo()
    {
        $currentVersionFull = PHP_VERSION;
        preg_match("#^\d+(\.\d+)*#", $currentVersionFull, $filtered);
        $currentVersion = $filtered[0];

        return [
            'full' => $currentVersionFull,
            'version' => $currentVersion
        ];
    }
728031
private function getServerVersion()
    {
        $connection = $this->getWrappedConnection();

        // Automatic platform version detection.
        if ($connection instanceof ServerInfoAwareConnection && ! $connection->requiresQueryForServerVersion()) {
            return $connection->getServerVersion();
        }

        // Unable to detect platform version.
        return null;
    }
199480
public function checkPhpVersion() {
		$phpVesion = $this->_modelConfigInstaller->getPhpVersionConfig();
		if (empty($phpVesion)) {
			return null;
		}

		$result = true;
		foreach ($phpVesion as $phpVesionItem) {
			if (!is_array($phpVesionItem)) {
				continue;
			}

			$phpVesionItem += ['', null];
			list($version, $operator) = $phpVesionItem;
			if (empty($operator)) {
				$operator = '==';
			}

			$checkResult = false;
			if (!empty($version)) {
				$checkResult = version_compare(PHP_VERSION, $version, $operator);
			}
			if (!$checkResult) {
				$result = false;
			}
		}

		return $result;
	}