diff --git a/composer.lock b/composer.lock index 8c9a1d6c2..3841369fb 100644 --- a/composer.lock +++ b/composer.lock @@ -83,12 +83,12 @@ "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "e639bd3c21f90c8368e6c4a87fd4491f8b21eb2c" + "reference": "594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/e639bd3c21f90c8368e6c4a87fd4491f8b21eb2c", - "reference": "e639bd3c21f90c8368e6c4a87fd4491f8b21eb2c", + "url": "https://api.github.com/repos/composer/semver/zipball/594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89", + "reference": "594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89", "shasum": "" }, "require": { @@ -156,7 +156,7 @@ "type": "tidelift" } ], - "time": "2020-05-19T14:21:25+00:00" + "time": "2020-05-19T14:49:33+00:00" }, { "name": "composer/spdx-licenses", diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index c531b3424..67eb2506c 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -648,14 +648,34 @@ EOF; return implode('.', $chunks); }; - $lowestOperator = $lowestPhpVersion->isInclusive() ? '>=' : '>'; - $highestOperator = $highestPhpVersion->isInclusive() ? '<=' : '<'; - $lowestPhpVersionId = $formatToPhpVersionId($lowestPhpVersion); - $highestPhpVersionId = $formatToPhpVersionId($highestPhpVersion); - $lowestPhpVersion = $formatToHumanReadable($lowestPhpVersion); - $highestPhpVersion = $formatToHumanReadable($highestPhpVersion); - $requiredExtensions = implode('', $requiredExtensions); + $requiredPhp = array(); + $requiredPhpError = array(); + if (!$lowestPhpVersion->isZero()) { + $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>'; + $requiredPhp[] = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion); + $requiredPhpError[] = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"'; + } + if (!$highestPhpVersion->isPositiveInfinity()) { + $operator = $highestPhpVersion->isInclusive() ? '<=' : '<'; + $requiredPhp[] = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($highestPhpVersion); + $requiredPhpError[] = '"'.$operator.' '.$formatToHumanReadable($highestPhpVersion).'"'; + } + if ($requiredPhp) { + $requiredPhp = implode(' && ', $requiredPhp); + $requiredPhpError = implode(' and ', $requiredPhpError); + $requiredPhp = <<= 0 && PHP_VERSION_ID < 80000)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 0" and "< 8.0.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID < 80000)) { + $issues[] = 'Your Composer dependencies require a PHP version "< 8.0.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php index 0cd09927a..f3ae3e071 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php @@ -4,10 +4,6 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 0 && PHP_VERSION_ID < 99999)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 0" and "< 99999". You are running ' . PHP_VERSION . '.'; -} - $missingExtensions = array(); extension_loaded('json') || $missingExtensions[] = 'json'; extension_loaded('xml') || $missingExtensions[] = 'xml'; diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php index 838cbbbba..85a922d49 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 70200 && PHP_VERSION_ID < 99999)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0" and "< 99999". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 70200)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php b/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php index d57294f0b..8056909d6 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php @@ -4,10 +4,6 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 0 && PHP_VERSION_ID < 99999)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 0" and "< 99999". You are running ' . PHP_VERSION . '.'; -} - $missingExtensions = array(); extension_loaded('pdo') || $missingExtensions[] = 'pdo';