Jelajahi Sumber

Merge branch '1.5'

Jordi Boggiano 7 tahun lalu
induk
melakukan
755482ddb1
2 mengubah file dengan 12 tambahan dan 2 penghapusan
  1. 4 0
      CHANGELOG.md
  2. 8 2
      src/Composer/Command/InitCommand.php

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+### [1.5.4] - 2017-12-01
+
+  * Fixed regression in require command when requiring unstable packages
+
 ### [1.5.3] - 2017-11-30
 
   * Fixed require/remove commands reverting the composer.json change when a non-solver-related error occurs

+ 8 - 2
src/Composer/Command/InitCommand.php

@@ -395,7 +395,7 @@ EOT
                     ));
                 } else {
                     // check that the specified version/constraint exists before we proceed
-                    $this->findBestVersionForPackage($input, $requirement['name'], $phpVersion, $preferredStability, $requirement['version']);
+                    $this->findBestVersionForPackage($input, $requirement['name'], $phpVersion, 'dev', $requirement['version']);
                 }
 
                 $result[] = $requirement['name'] . ' ' . $requirement['version'];
@@ -671,6 +671,12 @@ EOT
 
         if (!$package) {
             if ($requiredVersion && $versionSelector->findBestCandidate($name, null, $phpVersion, $preferredStability)) {
+                // Check whether the PHP version was the problem
+                if ($phpVersion && $versionSelector->findBestCandidate($name, null, null, $preferredStability)) {
+                    throw new \InvalidArgumentException(sprintf(
+                        'Package %s at version %s has a PHP requirement incompatible with your PHP version (%s)', $name, $requiredVersion, $phpVersion
+                    ));
+                }
                 throw new \InvalidArgumentException(sprintf(
                     'Could not find package %s in a version matching %s', $name, $requiredVersion
                 ));
@@ -678,7 +684,7 @@ EOT
             // Check whether the PHP version was the problem
             if ($phpVersion && $versionSelector->findBestCandidate($name)) {
                 throw new \InvalidArgumentException(sprintf(
-                    'Could not find package %s at any version matching your PHP version %s', $name, $phpVersion
+                    'Could not find package %s in any version matching your PHP version (%s)', $name, $phpVersion
                 ));
             }