Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 33e4966

Browse files
committed
Fixes for PR #90 (thx @xabbuh)
1 parent f75f252 commit 33e4966

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/Symfony/Installer/NewCommand.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,17 @@ private function checkSymfonyVersionIsInstallable()
128128
throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99');
129129
}
130130

131-
if (preg_match('/^2\.\d$/', $this->version)) {
131+
if (preg_match('/^(2\.\d\.\d{1,2})|(2\.\d)$/', $this->version)) {
132132
// Check if we have a minor version
133133

134-
$json = @file_get_contents('http://symfony.com/versions.json');
134+
$client = new Client();
135+
$json = $client->get('http://symfony.com/versions.json')->getBody()->getContents();
135136

136-
if (false !== $json) {
137+
if ($json) {
137138
$versionsList = GuzzleHttp\json_decode($json, true);
138-
if (isset($versionsList[$this->version]) && in_array($versionsList[$this->version], $versionsList['installable'])) {
139+
if (isset($versionsList[$this->version])) {
139140
// Get the latest installable of the minor version the user asked
140141
$this->version = $versionsList[$this->version];
141-
} else {
142-
throw new \RuntimeException(sprintf(
143-
"The selected version (%s) cannot be installed because it is not\n".
144-
"supported, or is considered as not installable for security reasons.\n".
145-
"To solve this issue, install Symfony with the latest available version by\n".
146-
"specifying no version, or simply using \"latest\" keyword as version name:\n%s",
147-
$this->version,
148-
$this->getExecutedCommand('latest')
149-
));
150142
}
151143
}
152144
}
@@ -265,7 +257,7 @@ private function download()
265257
));
266258
} else {
267259
throw new \RuntimeException(sprintf(
268-
"The selected version (%s) couldn\'t be downloaded because of the following error:\n%s",
260+
"The selected version (%s) couldn't be downloaded because of the following error:\n%s",
269261
$this->version,
270262
$e->getMessage()
271263
));

0 commit comments

Comments
 (0)