1
0
Fork 0

Avoid checking for unbounded constraints in platform checks

pull/8918/head
Jordi Boggiano 2020-05-19 17:15:08 +02:00
parent 62d0443e07
commit 45d3e133a4
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
6 changed files with 36 additions and 28 deletions

8
composer.lock generated
View File

@ -83,12 +83,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/semver.git", "url": "https://github.com/composer/semver.git",
"reference": "e639bd3c21f90c8368e6c4a87fd4491f8b21eb2c" "reference": "594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/e639bd3c21f90c8368e6c4a87fd4491f8b21eb2c", "url": "https://api.github.com/repos/composer/semver/zipball/594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89",
"reference": "e639bd3c21f90c8368e6c4a87fd4491f8b21eb2c", "reference": "594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -156,7 +156,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-05-19T14:21:25+00:00" "time": "2020-05-19T14:49:33+00:00"
}, },
{ {
"name": "composer/spdx-licenses", "name": "composer/spdx-licenses",

View File

@ -648,14 +648,34 @@ EOF;
return implode('.', $chunks); return implode('.', $chunks);
}; };
$lowestOperator = $lowestPhpVersion->isInclusive() ? '>=' : '>'; $requiredPhp = array();
$highestOperator = $highestPhpVersion->isInclusive() ? '<=' : '<'; $requiredPhpError = array();
$lowestPhpVersionId = $formatToPhpVersionId($lowestPhpVersion); if (!$lowestPhpVersion->isZero()) {
$highestPhpVersionId = $formatToPhpVersionId($highestPhpVersion); $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
$lowestPhpVersion = $formatToHumanReadable($lowestPhpVersion); $requiredPhp[] = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
$highestPhpVersion = $formatToHumanReadable($highestPhpVersion); $requiredPhpError[] = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
$requiredExtensions = implode('', $requiredExtensions); }
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 = <<<PHP_CHECK
if (!($requiredPhp)) {
\$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
}
PHP_CHECK;
} else {
$requiredPhp = '';
}
$requiredExtensions = implode('', $requiredExtensions);
if ('' !== $requiredExtensions) { if ('' !== $requiredExtensions) {
$requiredExtensions = <<<EXT_CHECKS $requiredExtensions = <<<EXT_CHECKS
@ -674,11 +694,7 @@ EXT_CHECKS;
// platform_check.php @generated by Composer // platform_check.php @generated by Composer
\$issues = array(); \$issues = array();
${requiredPhp}${requiredExtensions}
if (!(PHP_VERSION_ID $lowestOperator $lowestPhpVersionId && PHP_VERSION_ID $highestOperator $highestPhpVersionId)) {
\$issues[] = 'Your Composer dependencies require a PHP version "$lowestOperator $lowestPhpVersion" and "$highestOperator $highestPhpVersion". You are running ' . PHP_VERSION . '.';
}
$requiredExtensions
if (\$issues) { if (\$issues) {
echo 'Composer detected issues in your platform:' . "\\n\\n" . implode("\\n", \$issues); echo 'Composer detected issues in your platform:' . "\\n\\n" . implode("\\n", \$issues);
exit(104); exit(104);

View File

@ -4,8 +4,8 @@
$issues = array(); $issues = array();
if (!(PHP_VERSION_ID >= 0 && PHP_VERSION_ID < 80000)) { if (!(PHP_VERSION_ID < 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 0" and "< 8.0.0". You are running ' . PHP_VERSION . '.'; $issues[] = 'Your Composer dependencies require a PHP version "< 8.0.0". You are running ' . PHP_VERSION . '.';
} }
if ($issues) { if ($issues) {

View File

@ -4,10 +4,6 @@
$issues = array(); $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(); $missingExtensions = array();
extension_loaded('json') || $missingExtensions[] = 'json'; extension_loaded('json') || $missingExtensions[] = 'json';
extension_loaded('xml') || $missingExtensions[] = 'xml'; extension_loaded('xml') || $missingExtensions[] = 'xml';

View File

@ -4,8 +4,8 @@
$issues = array(); $issues = array();
if (!(PHP_VERSION_ID >= 70200 && PHP_VERSION_ID < 99999)) { if (!(PHP_VERSION_ID >= 70200)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0" and "< 99999". You are running ' . PHP_VERSION . '.'; $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.';
} }
if ($issues) { if ($issues) {

View File

@ -4,10 +4,6 @@
$issues = array(); $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(); $missingExtensions = array();
extension_loaded('pdo') || $missingExtensions[] = 'pdo'; extension_loaded('pdo') || $missingExtensions[] = 'pdo';