Symfony\Installer\NewCommand::checkSymfonyVersionIsInstallable PHP Метод

checkSymfonyVersionIsInstallable() защищенный Метод

Due to the changes introduced in the Icu/Intl components (see http://symfony.com/blog/new-in-symfony-2-6-farewell-to-icu-component) not all the previous Symfony versions are installable by the installer. The rules to decide if the version is installable are as follows: - 2.0, 2.1, 2.2 and 2.4 cannot be installed because they are unmaintained. - 2.3 can be installed starting from version 2.3.21 (inclusive) - 2.5 can be installed starting from version 2.5.6 (inclusive) - 2.6, 2.7, 2.8 and 2.9 can be installed regardless the version.
    protected function checkSymfonyVersionIsInstallable()
    {
        // validate the given version syntax
        if (!preg_match('/^latest|lts|[2-9]\\.\\d(?:\\.\\d{1,2})?(?:-(?:dev|BETA\\d*|RC\\d*))?$/i', $this->version)) {
            throw new \RuntimeException(sprintf("The Symfony version can be a branch number (e.g. 2.8), a full version\n" . "number (e.g. 3.1.4), a special word ('latest' or 'lts') and a unstable\n" . "version number (e.g. 3.2.0-rc1) but '%s' was given.", $this->version));
        }
        // Get the full list of Symfony versions to check if it's installable
        $client = $this->getGuzzleClient();
        $symfonyVersions = $client->get('http://symfony.com/versions.json')->json();
        if (empty($symfonyVersions)) {
            throw new \RuntimeException("There was a problem while downloading the list of Symfony versions from\n" . "symfony.com. Check that you are online and the following URL is accessible:\n\n" . 'http://symfony.com/versions.json');
        }
        // if a branch number is used, transform it into a real version number
        if (preg_match('/^[2-9]\\.\\d$/', $this->version)) {
            if (!isset($symfonyVersions[$this->version])) {
                throw new \RuntimeException(sprintf("The selected branch (%s) does not exist, or is not maintained.\n" . "To solve this issue, install Symfony with the latest stable release:\n\n" . '%s %s %s', $this->version, $_SERVER['PHP_SELF'], $this->getName(), $this->projectDir));
            }
            $this->version = $symfonyVersions[$this->version];
        }
        // if a special version name is used, transform it into a real version number
        if (in_array($this->version, array('latest', 'lts'))) {
            $this->version = $symfonyVersions[$this->version];
        }
        // versions are case-sensitive in the download server (3.1.0-rc1 must be 3.1.0-RC1)
        if ($isUnstableVersion = preg_match('/^.*\\-(BETA|RC)\\d*$/i', $this->version)) {
            $this->version = strtoupper($this->version);
        }
        $isNonInstallable = in_array($this->version, $symfonyVersions['non_installable']);
        $isInstallable = in_array($this->version, $symfonyVersions['installable']);
        // installable and non-installable versions are explicitly declared in the
        // list of versions; there is an edge-case: unstable versions are not listed
        // and they are generally installable (e.g. 3.1.0-RC1)
        if ($isNonInstallable || !$isInstallable && !$isUnstableVersion) {
            throw new \RuntimeException(sprintf("The selected version (%s) cannot be installed because it is not compatible\n" . "with this installer or because it hasn't been published as a package yet.\n" . "To solve this issue install Symfony manually executing the following command:\n\n" . 'composer create-project symfony/framework-standard-edition %s %s', $this->version, $this->projectDir, $this->version));
        }
        // check that the system has the PHP version required by the Symfony version to be installed
        if (version_compare($this->version, '3.0.0', '>=') && version_compare(phpversion(), '5.5.9', '<')) {
            throw new \RuntimeException(sprintf("The selected version (%s) cannot be installed because it requires\n" . "PHP 5.5.9 or higher and your system has PHP %s installed.\n", $this->version, phpversion()));
        }
        if ($isUnstableVersion) {
            $this->output->writeln("\n <bg=red> WARNING </> You are downloading an unstable Symfony version.");
        }
        return $this;
    }