Tasks.php
/**
     * 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.
This is a private helper method. It takes a semantic version contraint,
parsable by [Composer's Semver] and
resolves an actual wordpress version number.



@param  string $versionContraint A semantic version contraint.
@return string                                   A semantic version number.
Resolves a Wordpress Version Contraint . This is a private helper method . It takes a semantic version contraint parsable by [ Composer ' s Semver ] and resolves an actual wordpress version number . @param string $versionContraint A semantic version contraint . @return string A semantic version number .
private function wpResolveVersionNo(string $versionContraint)
    {
        $versionContraint = str_replace('v', '', $versionContraint);
        if ($versionContraint == '*')
        {
            $json = (new Http)->request('GET', self::$WP_VERSION_URL)->getBody();
            return json_decode($json, true)['offers'][0]['version'];
        }
        $html = (new Http)->request('GET', self::$WP_RELEASES_URL)->getBody()->getContents();
        preg_match_all("#><a href='https://wordpress\.org/wordpress-[^>]+#",
            $html, $matches
        );
        $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();
        return (string) Semver::satisfiedBy($versions, $versionContraint)[0];
    }
private function wpResolveVersionNo ( string $ versionContraint ) { $ versionContraint = str_replace ( 'v' , '' , $ versionContraint ) ; if ( $ versionContraint == '*' ) { $ json = ( new Http ) -> request ( 'GET' , self :: $ WP_VERSION_URL ) -> getBody ( ) ; return json_decode ( $ json , true ) [ 'offers' ] [ 0 ] [ 'version' ] ; } $ html = ( new Http ) -> request ( 'GET' , self :: $ WP_RELEASES_URL ) -> getBody ( ) -> getContents ( ) ; preg_match_all ( " #><a href='https://wordpress\.org/wordpress-[^>]+# " , $ html , $ matches ) ; $ 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 ( ) ; return ( string ) Semver :: satisfiedBy ( $ versions , $ versionContraint ) [ 0 ] ; }
Resolves a Wordpress Version Contraint.
Resolves a Wordpress Version Contraint .
// Remove a v at the start if it exists // If the constraint it a single wildcard, lets just // return the latest stable release of wordpress. // Download the releases from the wordpress site. // Extract a list of download links, these contain the versions. // Filter the links to obtain a list of just versions // Let semver take over and work it's magic