@param $versions

@return mixed
426896
private function handleVersions($versions)
    {
        foreach ($versions as $version => $info) {
            $announcement = $this->handleAnnouncement($version, $info);
            $date = $this->handleDate($info);

            $sources = [];

            foreach ($info['source'] as $source) {
                if (!isset($source['filename'])) {
                    continue;
                }

                foreach (['md5', 'sha256'] as $index) {
                    if (!isset($source[$index])) {
                        $source[$index] = null;
                    }
                }

                if (isset($source['date'])) {
                    unset($source['date']);
                }

                $sources[preg_replace('~.*\.~', '', $source['filename'])] = $source;
            }

            $versions[$version] = [
                'version' => $version,
                'aliases' => [],
                'announcement' => $announcement,
                'date' => date('Y-m-d', strtotime($date)),
                'source' => $sources,
                'museum' => isset($info['museum']) ? (boolean)$info['museum'] : false,
                'xdebug' => $this->getXdebugInfo($version),
                'gpg' => $this->getGpgInfo($version),
            ];
        }

        return $versions;
    }
491688
public static function getVersion(string $version = ''): string
    {
        if ($version === '') {
            $version = PrettyVersions::getVersion('api-clients/pusher')->getFullVersion();
        }

        list($version, $hash) = explode('@', $version);

        if (strpos($version, 'dev') !== false) {
            return '0.0.1-' . $hash;
        }

        return $version;
    }
92060
private function setVersionFromRequest(array $versions)
    {
        $this->setDefaultVersion($versions);

        foreach ($versions as $v) {
            if ($v->canParseRequest()) {
                $this->version = $v;
                break;
            }
        }
    }
1359027
protected function getCompareVersion(Version $version)
    {
        if ($version->isDev()) {
            return substr(
                $version->getFullPretty(),
                strlen($version->getPretty()) + 1
            );
        }

        return $version->getPretty();
    }
422570
public function asVersion($version) {
        $result = array();

        foreach (get_object_vars($this) as $property => $value) {
            //
            // skip properties that start with an underscore to allow
            // storing information that isn't included in statement
            // structure etc. (see Attachment.content for example)
            //
            if (strpos($property, '_') === 0) {
                continue;
            }

            if ($value instanceof VersionableInterface) {
                $value = $value->asVersion($version);
            }
            elseif (is_array($value) && !empty($value)) {
                $tmp_value = array();
                foreach ($value as $element) {
                    if ($element instanceof VersionableInterface) {
                        array_push($tmp_value, $element->asVersion($version));
                    }
                    else {
                        array_push($tmp_value, $element);
                    }
                }
                $value = $tmp_value;
            }

            if (isset($value) && (!is_array($value) || !empty($value))) {
                $result[$property] = $value;
            }
        }

        if (method_exists($this, '_asVersion')) {
            $this->_asVersion($result, $version);
        }

        return $result;
    }
1016471
public function importVersion($version)
    {
        return $this
            ->setMajor($version->getMajor())
            ->setMinor($version->getMinor())
            ->setPatch($version->getPatch())
            ->setPreRelease($version->getPreRelease())
            ->setBuild($version->getBuild());
    }
1139947
public function groupVersions($results)
    {
        $property = $this->versionAssociation()->getProperty();

        return $results->map(function (EntityInterface $row) use ($property) {
            $versionField = $this->_config['versionField'];
            $versions = (array)$row->get($property);
            $grouped = new Collection($versions);

            $result = [];
            foreach ($grouped->combine('field', 'content', 'version_id') as $versionId => $keys) {
                $entityClass = $this->_table->getEntityClass();
                $versionData = [
                    $versionField => $versionId
                ];

                $keys = $this->_convertFieldsToType($keys, 'toPHP');

                /* @var \Cake\Datasource\EntityInterface $versionRow */
                $versionRow = $grouped->match(['version_id' => $versionId])->first();

                foreach ($this->_config['additionalVersionFields'] as $mappedField => $field) {
                    if (!is_string($mappedField)) {
                        $mappedField = 'version_' . $field;
                    }
                    $versionData[$mappedField] = $versionRow->get($field);
                }

                $version = new $entityClass($keys + $versionData, [
                    'markNew' => false,
                    'useSetters' => false,
                    'markClean' => true
                ]);
                $result[$versionId] = $version;
            }

            $options = ['setter' => false, 'guard' => false];
            $row->set('_versions', $result, $options);
            unset($row[$property]);
            $row->clean();

            return $row;
        });
    }
1015775
public function withProtocolVersions(array $versions): self {
        $versions = \array_unique($versions);

        if (empty($versions)) {
            throw new \Error("Empty array of protocol versions provided, must not be empty.");
        }

        foreach ($versions as $version) {
            if (!\in_array($version, ["1.0", "1.1", "2.0"], true)) {
                throw new \Error(
                    "Invalid HTTP protocol version: " . $version
                );
            }
        }

        if ($this->protocolVersions === $versions) {
            return $this;
        }

        $clone = clone $this;
        $clone->protocolVersions = $versions;

        return $clone;
    }
128882
public function getVersions()
    {
        $this->createIfNotExists();
        $sql = 'SELECT version FROM schema_migration ORDER BY version DESC';
        $versions = array();
        foreach ($this->connection->query($sql) as $row) {
            $versions[] = $row['version'];
        }

        return $versions;
    }
738282
public static function toVersion($version)
    {
        $components = self::toComponents($version);

        return new Version(
            $components['major'],
            $components['minor'],
            $components['patch'],
            $components['pre'],
            $components['build']
        );
    }
250649
public function getHighestVersion(array $versions = []): string
    {
        $highest_version = 0;
        foreach ($versions as $version_number) {
            if ($version_number === 'dev-master') {
                continue;
            }
            if (str_replace('.', '', $version_number)+0 > $highest_version) {
                $highest_version = $version_number;
            }
        }
        if ($highest_version == 0) {
            return 'dev-master';
        }

        return $highest_version;
    }
1002494
public function getVersions()
    {
        while (
            !empty($this->version) &&
            substr_count($this->version, '.') < 2
        ) {
            $this->version .= '.0';
        }
        // Remove part by part of the version.
        $result = array_merge(
            [$this->version],
            $this->explode($this->version, '.')
        );
        asort($result);
        usort($result, function ($a, $b) {
            // PHP 7: Switch to the <=> "Spaceship" operator
            return strlen($b) - strlen($a);
        });
        return $this->filterDuplicates($result);
    }
1325118
private function resolveVersion($version)
    {
        if (isset($this->aliases[$version])) {
            $version = $this->aliases[$version];

            return $version;
        }

        return $version;
    }
341543
public function selectVersion($version)
	{
		if ( ! in_array($version, $this->versions))
		{
			// not a value version
			return false;
		}

		$this->version = $version;

		return $this;
	}
1100248
public function getMigrationVersion($version)
    {
        if ($this->isVersionAvailable($version)) {
            if ($this->isVersionLoaded($version)) {
                $configuration = $this->loadedVersions[$version];
            } else {
                $configuration = $this->loadConfiguration($version);
                $this->loadedVersions[$version] = $configuration;
            }
            return $configuration;
        }
        throw new MigrationException('Specified version is not available.', 1345821746);
    }
1357835
private function get_versions() {
            $versions = array();
            $versions['platform_version']             = get_bloginfo( 'version' );
            $versions['sdk_version']                  = $this->version;
            $versions['programming_language_version'] = phpversion();

            foreach ( $versions as $k => $version ) {
                if ( is_string( $versions[ $k ] ) && ! empty( $versions[ $k ] ) ) {
                    $versions[ $k ] = substr( $versions[ $k ], 0, 16 );
                }
            }

            return $versions;
        }
1301005
public static function getByVersionNumber($version)
    {
        $updates = id(new Update())->getLocalAvailableUpdates();
        foreach ($updates as $up) {
            if ($up->getUpdateVersion() == $version) {
                return $up;
            }
        }
    }