function AutoloadGenerator::getAutoloadRealFile
Parameters
string $vendorPathCode unused in this method:
string $appBaseDirCode unused in this method:
string $prependAutoloader 'true'|'false':
Return value
string
1 call to AutoloadGenerator::getAutoloadRealFile()
- AutoloadGenerator::dump in vendor/
composer/ composer/ src/ Composer/ Autoload/ AutoloadGenerator.php
File
-
vendor/
composer/ composer/ src/ Composer/ Autoload/ AutoloadGenerator.php, line 992
Class
- AutoloadGenerator
- @author Igor Wiedler <igor@wiedler.ch> @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\AutoloadCode
protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform) {
$file = <<<HEADER
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit{<span class="php-variable">$suffix</span>}
{
private static \$loader;
public static function loadClassLoader(\$class)
{
if ('Composer\\Autoload\\ClassLoader' === \$class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \\Composer\\Autoload\\ClassLoader
*/
public static function getLoader()
{
if (null !== self::\$loader) {
return self::\$loader;
}
HEADER;
if ($checkPlatform) {
$file .= <<<'PLATFORM_CHECK'
require __DIR__ . '/platform_check.php';
PLATFORM_CHECK;
}
$file .= <<<CLASSLOADER_INIT
spl_autoload_register(array('ComposerAutoloaderInit{<span class="php-variable">$suffix</span>}', 'loadClassLoader'), true, {<span class="php-variable">$prependAutoloader</span>});
self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit{<span class="php-variable">$suffix</span>}', 'loadClassLoader'));
CLASSLOADER_INIT;
if ($useIncludePath) {
$file .= <<<'INCLUDE_PATH'
$includePaths = require __DIR__ . '/include_paths.php';
$includePaths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $includePaths));
INCLUDE_PATH;
}
// keeping PHP 5.6+ compatibility for the autoloader here by using call_user_func vs getInitializer()()
$file .= <<<STATIC_INIT
require __DIR__ . '/autoload_static.php';
call_user_func(\\Composer\\Autoload\\ComposerStaticInit{<span class="php-variable">$suffix</span>}::getInitializer(\$loader));
STATIC_INIT;
if ($this->classMapAuthoritative) {
$file .= <<<'CLASSMAPAUTHORITATIVE'
$loader->setClassMapAuthoritative(true);
CLASSMAPAUTHORITATIVE;
}
if ($this->apcu) {
$apcuPrefix = var_export($this->apcuPrefix !== null ? $this->apcuPrefix : bin2hex(random_bytes(10)), true);
$file .= <<<APCU
\$loader->setApcuPrefix({<span class="php-variable">$apcuPrefix</span>});
APCU;
}
if ($useGlobalIncludePath) {
$file .= <<<'INCLUDEPATH'
$loader->setUseIncludePath(true);
INCLUDEPATH;
}
if ($targetDirLoader) {
$file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
spl_autoload_register(array('ComposerAutoloaderInit{<span class="php-variable">$suffix</span>}', 'autoload'), true, true);
REGISTER_TARGET_DIR_AUTOLOAD;
}
$file .= <<<REGISTER_LOADER
\$loader->register({<span class="php-variable">$prependAutoloader</span>});
REGISTER_LOADER;
if ($useIncludeFiles) {
$file .= <<<INCLUDE_FILES
\$filesToLoad = \\Composer\\Autoload\\ComposerStaticInit{<span class="php-variable">$suffix</span>}::\$files;
\$requireFile = \\Closure::bind(static function (\$fileIdentifier, \$file) {
if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
\$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
require \$file;
}
}, null, null);
foreach (\$filesToLoad as \$fileIdentifier => \$file) {
\$requireFile(\$fileIdentifier, \$file);
}
INCLUDE_FILES;
}
$file .= <<<METHOD_FOOTER
return \$loader;
}
METHOD_FOOTER;
$file .= $targetDirLoader;
return $file . <<<FOOTER
}
FOOTER;
}