Tasks.php
private function wpResolveVersionNo(string $versionContraint)
    {
        // Remove a v at the start if it exists
        $versionContraint = str_replace('v', '', $versionContraint);

        // If the constraint it a single wildcard, lets just
        // return the latest stable release of wordpress.
        if ($versionContraint == '*')
        {
            $json = (new Http)->request('GET', self::$WP_VERSION_URL)->getBody();
            return json_decode($json, true)['offers'][0]['version'];
        }

        // Download the releases from the wordpress site.
        $html = (new Http)->request('GET', self::$WP_RELEASES_URL)->getBody()->getContents();

        // Extract a list of download links, these contain the versions.
        preg_match_all("#><a href='https://wordpress\.org/wordpress-[^>]+#",
            $html, $matches
        );

        // Filter the links to obtain a list of just versions
        $versions = Linq::from($matches[0])
        ->select(function(string $v){ return Str::s($v); })
        ->where(function(Str $v){ return $v->endsWith(".zip'"); })
        ->where(function(Str $v){ return !$v->contains('IIS'); })
        ->where(function(Str $v){ return !$v->contains('mu'); })
        ->select(function(Str $v){ return $v->between('wordpress-', '.zip'); })
        ->where(function(Str $v)
        {
            if ($v->contains('-'))
            {
                return preg_match("#.*-(dev|beta|alpha|rc).*#i", (string)$v) === 1;
            }

            return true;
        })
        ->toArray();

        // Let semver take over and work it's magic
        return (string) Semver::satisfiedBy($versions, $versionContraint)[0];
    }
private function wpResolveVersionNo(string $versionContraint)
    {
        // Remove a v at the start if it exists
        $versionContraint = str_replace('v', '', $versionContraint);

        // If the constraint it a single wildcard, lets just
        // return the latest stable release of wordpress.
        if ($versionContraint == '*')
        {
            $json = (new Http)->request('GET', self::$WP_VERSION_URL)->getBody();
            return json_decode($json, true)['offers'][0]['version'];
        }

        // Download the releases from the wordpress site.
        $html = (new Http)->request('GET', self::$WP_RELEASES_URL)->getBody()->getContents();

        // Extract a list of download links, these contain the versions.
        preg_match_all("#><a href='https://wordpress\.org/wordpress-[^>]+#",
            $html, $matches
        );

        // Filter the links to obtain a list of just versions
        $versions = Linq::from($matches[0])
        ->select(function(string $v){ return Str::s($v); })
        ->where(function(Str $v){ return $v->endsWith(".zip'"); })
        ->where(function(Str $v){ return !$v->contains('IIS'); })
        ->where(function(Str $v){ return !$v->contains('mu'); })
        ->select(function(Str $v){ return $v->between('wordpress-', '.zip'); })
        ->where(function(Str $v)
        {
            if ($v->contains('-'))
            {
                return preg_match("#.*-(dev|beta|alpha|rc).*#i", (string)$v) === 1;
            }

            return true;
        })
        ->toArray();

        // Let semver take over and work it's magic
        return (string) Semver::satisfiedBy($versions, $versionContraint)[0];
    }
private function wpResolveVersionNo ( string $ versionContraint ) { // Remove a v at the start if it exists $ versionContraint = str_replace ( 'v' , '' , $ versionContraint ) ; // If the constraint it a single wildcard, lets just // return the latest stable release of wordpress. if ( $ versionContraint == '*' ) { $ json = ( new Http ) -> request ( 'GET' , self :: $ WP_VERSION_URL ) -> getBody ( ) ; return json_decode ( $ json , true ) [ 'offers' ] [ 0 ] [ 'version' ] ; } // Download the releases from the wordpress site. $ html = ( new Http ) -> request ( 'GET' , self :: $ WP_RELEASES_URL ) -> getBody ( ) -> getContents ( ) ; // Extract a list of download links, these contain the versions. preg_match_all ( "#><a href='https://wordpress\.org/wordpress-[^>]+#" , $ html , $ matches ) ; // Filter the links to obtain a list of just versions $ versions = Linq :: from ( $ matches [ 0 ] ) -> select ( function ( string $ v ) { return Str :: s ( $ v ) ; } ) -> where ( function ( Str $ v ) { return $ v -> endsWith ( ".zip'" ) ; } ) -> where ( function ( Str $ v ) { return ! $ v -> contains ( 'IIS' ) ; } ) -> where ( function ( Str $ v ) { return ! $ v -> contains ( 'mu' ) ; } ) -> select ( function ( Str $ v ) { return $ v -> between ( 'wordpress-' , '.zip' ) ; } ) -> where ( function ( Str $ v ) { if ( $ v -> contains ( '-' ) ) { return preg_match ( "#.*-(dev|beta|alpha|rc).*#i" , ( string ) $ v ) === 1 ; } return true ; } ) -> toArray ( ) ; // Let semver take over and work it's magic return ( string ) Semver :: satisfiedBy ( $ versions , $ versionContraint ) [ 0 ] ; }
Resolves a Wordpress Version Contraint.

This is a private helper method. It takes a semantic version contraint,
parsable by [Composer's Semver](https://github.com/composer/semver) and
resolves an actual wordpress version number.

We use this page: http://wordpress.org/download/release-archive/
As an offical list of released versions.

@param  string $versionContraint A semantic version contraint.
@return string 					A semantic version number.
Resolves a Wordpress Version Contraint .