Merge remote-tracking branch 'jeskew/feature/require_files_but_once'
commit
9710b26d3f
|
@ -475,8 +475,9 @@ EOF;
|
|||
protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
|
||||
{
|
||||
$filesCode = '';
|
||||
foreach ($files as $functionFile) {
|
||||
$filesCode .= ' '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).",\n";
|
||||
foreach ($files as $fileIdentifier => $functionFile) {
|
||||
$filesCode .= ' ' . $fileIdentifier . ' => '
|
||||
. $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
|
||||
}
|
||||
|
||||
if (!$filesCode) {
|
||||
|
@ -649,8 +650,8 @@ REGISTER_LOADER;
|
|||
if ($useIncludeFiles) {
|
||||
$file .= <<<INCLUDE_FILES
|
||||
\$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach (\$includeFiles as \$file) {
|
||||
composerRequire$suffix(\$file);
|
||||
foreach (\$includeFiles as \$fileIdentifier => \$file) {
|
||||
composerRequire$suffix(\$fileIdentifier, \$file);
|
||||
}
|
||||
|
||||
|
||||
|
@ -668,9 +669,17 @@ METHOD_FOOTER;
|
|||
return $file . <<<FOOTER
|
||||
}
|
||||
|
||||
function composerRequire$suffix(\$file)
|
||||
function composerRequire$suffix(\$fileIdentifier, \$file)
|
||||
{
|
||||
if (empty(\$GLOBALS['composerRequiredFiles'])) {
|
||||
\$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty(\$GLOBALS['composerRequiredFiles'][\$fileIdentifier])) {
|
||||
require \$file;
|
||||
|
||||
\$GLOBALS['composerRequiredFiles'][\$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
||||
FOOTER;
|
||||
|
@ -742,7 +751,11 @@ FOOTER;
|
|||
|
||||
$relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
|
||||
|
||||
if ($type === 'files' || $type === 'classmap') {
|
||||
if ($type === 'files') {
|
||||
$autoloads[var_export($this->getFileIdentifier($relativePath), true)]
|
||||
= $relativePath;
|
||||
continue;
|
||||
} elseif ($type === 'classmap') {
|
||||
$autoloads[] = $relativePath;
|
||||
continue;
|
||||
}
|
||||
|
@ -755,6 +768,11 @@ FOOTER;
|
|||
return $autoloads;
|
||||
}
|
||||
|
||||
protected function getFileIdentifier($path)
|
||||
{
|
||||
return md5_file($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts packages by dependency weight
|
||||
*
|
||||
|
|
|
@ -1069,8 +1069,8 @@ EOF;
|
|||
$this->assertEquals($expectedNamespace, file_get_contents($vendorDir.'/composer/autoload_namespaces.php'));
|
||||
$this->assertEquals($expectedPsr4, file_get_contents($vendorDir.'/composer/autoload_psr4.php'));
|
||||
$this->assertEquals($expectedClassmap, file_get_contents($vendorDir.'/composer/autoload_classmap.php'));
|
||||
$this->assertContains("\n \$vendorDir . '/b/b/bootstrap.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertContains("\n \$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertContains("\$vendorDir . '/b/b/bootstrap.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertContains("\$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
}
|
||||
|
||||
public function testUpLevelRelativePaths()
|
||||
|
@ -1147,7 +1147,7 @@ EOF;
|
|||
$this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
|
||||
$this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir.'/composer/autoload_psr4.php'));
|
||||
$this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
|
||||
$this->assertContains("\n \$baseDir . '/../test.php',\n", file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertContains("\$baseDir . '/../test.php',\n", file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
|
||||
}
|
||||
|
||||
public function testEmptyPaths()
|
||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$baseDir . '/foo.php',
|
||||
$baseDir . '/bar.php',
|
||||
'25b429360a61ca2629fdf9a4f484981c' => $baseDir . '/foo.php',
|
||||
'524f65941cc9a0fa65ff0ec097ccde8a' => $baseDir . '/bar.php',
|
||||
);
|
||||
|
|
|
@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$baseDir . '/devfiles/foo.php',
|
||||
'fc1e99cd93a6aa58e3b1565e688bcd87' => $baseDir . '/devfiles/foo.php',
|
||||
);
|
||||
|
|
|
@ -6,9 +6,9 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$vendorDir . '/a/a/test.php',
|
||||
$vendorDir . '/b/b/test2.php',
|
||||
$vendorDir . '/c/c/foo/bar/test3.php',
|
||||
$vendorDir . '/c/c/foo/bar/test4.php',
|
||||
$baseDir . '/root.php',
|
||||
'b18a3c4a24b1dc69fdd96098e5c28e01' => $vendorDir . '/a/a/test.php',
|
||||
'93797e35718fdafb825b1fe25c08a92c' => $vendorDir . '/b/b/test2.php',
|
||||
'a57008eef928ced7c299bfea724d8441' => $vendorDir . '/c/c/foo/bar/test3.php',
|
||||
'32e13a06a803ac6553a93454bcd3d2da' => $vendorDir . '/c/c/foo/bar/test4.php',
|
||||
'504bb142db8acef729eeeb06b0aedec5' => $baseDir . '/root.php',
|
||||
);
|
||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$baseDir . '/foo.php',
|
||||
$baseDir . '/bar.php',
|
||||
'25b429360a61ca2629fdf9a4f484981c' => $baseDir . '/foo.php',
|
||||
'524f65941cc9a0fa65ff0ec097ccde8a' => $baseDir . '/bar.php',
|
||||
);
|
||||
|
|
|
@ -41,15 +41,23 @@ class ComposerAutoloaderInitFilesAutoloadOrder
|
|||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequireFilesAutoloadOrder($file);
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireFilesAutoloadOrder($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequireFilesAutoloadOrder($file)
|
||||
function composerRequireFilesAutoloadOrder($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,15 +41,23 @@ class ComposerAutoloaderInitFilesAutoload
|
|||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequireFilesAutoload($file);
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireFilesAutoload($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequireFilesAutoload($file)
|
||||
function composerRequireFilesAutoload($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,15 @@ class ComposerAutoloaderInitIncludePath
|
|||
}
|
||||
}
|
||||
|
||||
function composerRequireIncludePath($file)
|
||||
function composerRequireIncludePath($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ class ComposerAutoloaderInitTargetDir
|
|||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequireTargetDir($file);
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireTargetDir($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -69,7 +69,15 @@ class ComposerAutoloaderInitTargetDir
|
|||
}
|
||||
}
|
||||
|
||||
function composerRequireTargetDir($file)
|
||||
function composerRequireTargetDir($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue