1
0
Fork 0

Add platform-check config option to disable platform_check.php generation, and disable it for Composer

pull/8820/head
Jordi Boggiano 2020-04-21 15:25:35 +02:00
parent afa18f2092
commit 2c8a4a1b93
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
8 changed files with 38 additions and 6 deletions

View File

@ -52,7 +52,8 @@
"config": {
"platform": {
"php": "5.3.9"
}
},
"platform-check": false
},
"extra": {
"branch-alias": {

View File

@ -307,4 +307,9 @@ in the composer home, cache, and data directories.
Defaults to `true`. If set to `false`, Composer will not create a `composer.lock`
file.
## platform-check
Defaults to `true`. If set to `false`, Composer will not create and require a
`platform_check.php` file as part of the autoloader bootstrap.
← [Repositories](05-repositories.md) | [Community](07-community.md) →

View File

@ -306,6 +306,10 @@
"lock": {
"type": "boolean",
"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."
}
}
},

View File

@ -312,9 +312,14 @@ EOF;
unlink($includeFilesFilePath);
}
$this->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
$this->filePutContentsIfModified($targetDir.'/platform_check.php', $this->getPlatformCheck($packageMap));
$checkPlatform = $config->get('platform-check');
if ($checkPlatform) {
$this->filePutContentsIfModified($targetDir.'/platform_check.php', $this->getPlatformCheck($packageMap));
} elseif (file_exists($targetDir.'/platform_check.php')) {
unlink($targetDir.'/platform_check.php');
}
$this->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
$this->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion));
$this->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
$this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
$this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
@ -687,7 +692,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
AUTOLOAD;
}
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion = 70000)
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
{
$file = <<<HEADER
<?php
@ -714,14 +719,24 @@ class ComposerAutoloaderInit$suffix
return self::\$loader;
}
HEADER;
if ($checkPlatform) {
$file .= <<<'PLATFORM_CHECK'
require __DIR__ . '/platform_check.php';
PLATFORM_CHECK;
}
$file .= <<<CLASSLOADER_INIT
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
HEADER;
CLASSLOADER_INIT;
if ($useIncludePath) {
$file .= <<<'INCLUDE_PATH'

View File

@ -421,6 +421,7 @@ EOT
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
'lock' => array($booleanValidator, $booleanNormalizer),
'platform-check' => array($booleanValidator, $booleanNormalizer),
);
$multiConfigValues = array(
'github-protocols' => array(

View File

@ -139,7 +139,9 @@ class Compiler
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/autoload_files.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/autoload_real.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/autoload_static.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/platform_check.php'));
if (file_exists(__DIR__.'/../../vendor/composer/platform_check.php')) {
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/platform_check.php'));
}
if (file_exists(__DIR__.'/../../vendor/composer/include_paths.php')) {
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/include_paths.php'));
}

View File

@ -64,6 +64,7 @@ class Config
'htaccess-protect' => true,
'use-github-api' => true,
'lock' => true,
'platform-check' => true,
// valid keys without defaults (auth config stuff):
// bitbucket-oauth
// github-oauth

View File

@ -101,6 +101,9 @@ class AutoloadGeneratorTest extends TestCase
'vendor-dir' => function () use ($that) {
return $that->vendorDir;
},
'platform-check' => function () {
return true;
},
);
$this->config->expects($this->atLeastOnce())