1
0
Fork 0

Merge pull request #5183 from nicolas-grekas/php56-wa

Workaround https://bugs.php.net/68057
pull/5191/head
Jordi Boggiano 2016-04-12 09:12:34 +01:00
commit de7123097e
1 changed files with 13 additions and 6 deletions

View File

@ -283,9 +283,9 @@ EOF;
} elseif (file_exists($includeFilesFilePath)) { } elseif (file_exists($includeFilesFilePath)) {
unlink($includeFilesFilePath); unlink($includeFilesFilePath);
} }
file_put_contents($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader)); file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion));
file_put_contents($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath));
$this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php'); $this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
$this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE'); $this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
@ -538,7 +538,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
AUTOLOAD; AUTOLOAD;
} }
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader) protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion = 70000)
{ {
$file = <<<HEADER $file = <<<HEADER
<?php <?php
@ -580,7 +580,7 @@ INCLUDE_PATH;
} }
$file .= <<<STATIC_INIT $file .= <<<STATIC_INIT
if (PHP_VERSION_ID >= 50600) { if (PHP_VERSION_ID >= $staticPhpVersion) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader)); call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
@ -646,7 +646,7 @@ REGISTER_LOADER;
if ($useIncludeFiles) { if ($useIncludeFiles) {
$file .= <<<INCLUDE_FILES $file .= <<<INCLUDE_FILES
if (PHP_VERSION_ID >= 50600) { if (PHP_VERSION_ID >= $staticPhpVersion) {
\$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files; \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
} else { } else {
\$includeFiles = require __DIR__ . '/autoload_files.php'; \$includeFiles = require __DIR__ . '/autoload_files.php';
@ -689,8 +689,10 @@ FOOTER;
FOOTER; FOOTER;
} }
protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath) protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
{ {
$staticPhpVersion = 50600;
$file = <<<HEADER $file = <<<HEADER
<?php <?php
@ -744,6 +746,11 @@ HEADER;
} }
foreach ($maps as $prop => $value) { foreach ($maps as $prop => $value) {
if (count($value) > 32767) {
// Static arrays are limited to 32767 values on PHP 5.6
// See https://bugs.php.net/68057
$staticPhpVersion = 70000;
}
$value = var_export($value, true); $value = var_export($value, true);
$value = str_replace($absoluteVendorPathCode, $vendorPathCode, $value); $value = str_replace($absoluteVendorPathCode, $vendorPathCode, $value);
$value = str_replace($absoluteAppBaseDirCode, $appBaseDirCode, $value); $value = str_replace($absoluteAppBaseDirCode, $appBaseDirCode, $value);