@ -208,7 +208,6 @@ class AutoloadGenerator
$filesystem->ensureDirectoryExists($targetDir);
$vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
$vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
$vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
$appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
@ -219,7 +218,7 @@ class AutoloadGenerator
// autoload_namespaces.php @generated by Composer
\$vendorDir = $vendorPathCode52 ;
\$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode;
return array(
@ -231,7 +230,7 @@ EOF;
// autoload_psr4.php @generated by Composer
\$vendorDir = $vendorPathCode52 ;
\$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode;
return array(
@ -279,7 +278,7 @@ EOF;
// autoload_classmap.php @generated by Composer
\$vendorDir = $vendorPathCode52 ;
\$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode;
return array(
@ -390,18 +389,18 @@ EOF;
$filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
$filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
$includePathFilePath = $targetDir.'/include_paths.php';
if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52 , $appBaseDirCode)) {
if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
$filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
} elseif (file_exists($includePathFilePath)) {
unlink($includePathFilePath);
}
$includeFilesFilePath = $targetDir.'/autoload_files.php';
if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52 , $appBaseDirCode)) {
if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
$filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
} elseif (file_exists($includeFilesFilePath)) {
unlink($includeFilesFilePath);
}
$filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion ));
$filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath));
$checkPlatform = $config->get('platform-check') & & !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter);
$platformCheckContent = null;
if ($checkPlatform) {
@ -416,7 +415,7 @@ EOF;
unlink($targetDir.'/platform_check.php');
}
$filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
$filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $ checkPlatform));
$filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform));
$filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
$filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
@ -938,11 +937,10 @@ AUTOLOAD;
* @param string $suffix
* @param bool $useGlobalIncludePath
* @param string $prependAutoloader 'true'|'false'
* @param string $staticPhpVersion
* @param bool $checkPlatform
* @return string
*/
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $ checkPlatform)
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform)
{
$file = < < < HEADER
<?php
@ -982,7 +980,7 @@ PLATFORM_CHECK;
$file .= < < < CLASSLOADER_INIT
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__) ));
self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__ ));
spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
@ -999,43 +997,12 @@ INCLUDE_PATH;
}
$file .= < < < STATIC_INIT
\$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion & & !defined('HHVM_VERSION') & & (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if (\$useStaticLoader) {
require __DIR__ . '/autoload_static.php';
require __DIR__ . '/autoload_static.php';
\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader)();
call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
} else {
STATIC_INIT;
if (!$this->classMapAuthoritative) {
$file .= < < < 'PSR04'
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
PSR04;
}
if ($useClassMap) {
$file .= < < < 'CLASSMAP'
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
CLASSMAP;
}
$file .= " }\n\n";
if ($this->classMapAuthoritative) {
$file .= < < < 'CLASSMAPAUTHORITATIVE'
$loader->setClassMapAuthoritative(true);
@ -1074,11 +1041,7 @@ REGISTER_LOADER;
if ($useIncludeFiles) {
$file .= < < < INCLUDE_FILES
if (\$useStaticLoader) {
\$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
} else {
\$includeFiles = require __DIR__ . '/autoload_files.php';
}
\$includeFiles = \Composer\Autoload\ComposerStaticInit$suffix::\$files;
foreach (\$includeFiles as \$fileIdentifier => \$file) {
composerRequire$suffix(\$fileIdentifier, \$file);
}
@ -1127,13 +1090,10 @@ FOOTER;
* @param string $targetDir
* @param string $vendorPath input for findShortestPathCode
* @param string $basePath input for findShortestPathCode
* @param string $staticPhpVersion
* @return string
*/
protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, & $staticPhpVersion )
protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath)
{
$staticPhpVersion = 50600;
$file = < < < HEADER
<?php
@ -1191,11 +1151,6 @@ HEADER;
}
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 = strtr(
var_export($value, true),
array(