Add platform check for 64-bit PHP (#11334)
parent
c23beac9c5
commit
f41abfca34
|
@ -720,6 +720,7 @@ EOF;
|
|||
protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
|
||||
{
|
||||
$lowestPhpVersion = Bound::zero();
|
||||
$requiredPhp64bit = false;
|
||||
$requiredExtensions = [];
|
||||
$extensionProviders = [];
|
||||
|
||||
|
@ -744,13 +745,17 @@ EOF;
|
|||
continue;
|
||||
}
|
||||
|
||||
if ('php' === $link->getTarget()) {
|
||||
if (in_array($link->getTarget(), ['php', 'php-64bit'], true)) {
|
||||
$constraint = $link->getConstraint();
|
||||
if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
|
||||
$lowestPhpVersion = $constraint->getLowerBound();
|
||||
}
|
||||
}
|
||||
|
||||
if ('php-64bit' === $link->getTarget()) {
|
||||
$requiredPhp64bit = true;
|
||||
}
|
||||
|
||||
if ($checkPlatform === true && Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
|
||||
// skip extension checks if they have a valid provider/replacer
|
||||
if (isset($extensionProviders[$match[1]])) {
|
||||
|
@ -823,6 +828,16 @@ if (!($requiredPhp)) {
|
|||
\$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
PHP_CHECK;
|
||||
}
|
||||
|
||||
if ($requiredPhp64bit) {
|
||||
$requiredPhp .= <<<PHP_CHECK
|
||||
|
||||
if (PHP_INT_SIZE !== 8) {
|
||||
\$issues[] = 'Your Composer dependencies require a 64-bit build of PHP.';
|
||||
}
|
||||
|
||||
PHP_CHECK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1861,6 +1861,18 @@ EOF;
|
|||
],
|
||||
'specific_php_release',
|
||||
],
|
||||
'Specific 64-bit PHP version' => [
|
||||
[
|
||||
'php-64bit' => new Link('a', 'php-64bit', $versionParser->parseConstraints('^7.2.8')),
|
||||
],
|
||||
'specific_php_64bit_required',
|
||||
],
|
||||
'64-bit PHP required' => [
|
||||
[
|
||||
'php-64bit' => new Link('a', 'php-64bit', $versionParser->parseConstraints('*')),
|
||||
],
|
||||
'php_64bit_required',
|
||||
],
|
||||
'No PHP required' => [
|
||||
[
|
||||
'ext-xml' => new Link('a', 'ext-xml', $versionParser->parseConstraints('*')),
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (PHP_INT_SIZE !== 8) {
|
||||
$issues[] = 'Your Composer dependencies require a 64-bit build of PHP.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 70208)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.8". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if (PHP_INT_SIZE !== 8) {
|
||||
$issues[] = 'Your Composer dependencies require a 64-bit build of PHP.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue