diff --git a/res/composer-schema.json b/res/composer-schema.json index e7c2c9fe8..7aa8fbd1a 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -312,8 +312,8 @@ "description": "Defaults to true. If set to false, Composer will not create a composer.lock file." }, "platform-check": { - "type": "boolean", - "description": "Defaults to true. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap." + "type": ["boolean", "string"], + "description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap." } } }, diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index a81ad49ab..ef29d4aad 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -350,7 +350,7 @@ EOF; $checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true; $platformCheckContent = null; if ($checkPlatform) { - $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array()); + $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array(), $config->get('platform-check')); if (null === $platformCheckContent) { $checkPlatform = false; } @@ -609,7 +609,7 @@ EOF; return $baseDir . (($path !== false) ? var_export($path, true) : ""); } - protected function getPlatformCheck($packageMap, array $ignorePlatformReqs) + protected function getPlatformCheck($packageMap, array $ignorePlatformReqs, $checkPlatform) { $lowestPhpVersion = Bound::zero(); $requiredExtensions = array(); @@ -637,7 +637,7 @@ EOF; } } - if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) { + if ($checkPlatform === true && preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) { // skip extension checks if they have a valid provider/replacer if (isset($extensionProviders[$match[1]])) { foreach ($extensionProviders[$match[1]] as $provided) { diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 94b2b6710..b0f26deb2 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -428,7 +428,18 @@ EOT 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer), 'htaccess-protect' => array($booleanValidator, $booleanNormalizer), 'lock' => array($booleanValidator, $booleanNormalizer), - 'platform-check' => array($booleanValidator, $booleanNormalizer), + 'platform-check' => array( + function ($val) { + return in_array($val, array('php-only', 'true', 'false', '1', '0'), true); + }, + function ($val) { + if ('php-only' === $val) { + return 'php-only'; + } + + return $val !== 'false' && (bool) $val; + }, + ), ); $multiConfigValues = array( 'github-protocols' => array( diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 76504c7ce..ab609dd43 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -65,7 +65,7 @@ class Config 'htaccess-protect' => true, 'use-github-api' => true, 'lock' => true, - 'platform-check' => true, + 'platform-check' => 'php-only', // valid keys without defaults (auth config stuff): // bitbucket-oauth // github-oauth