Move file identifier calculation to compile time
parent
24c4322672
commit
42b025776a
|
@ -410,8 +410,9 @@ EOF;
|
||||||
protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
|
protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
|
||||||
{
|
{
|
||||||
$filesCode = '';
|
$filesCode = '';
|
||||||
foreach ($files as $functionFile) {
|
foreach ($files as $fileIdentifier => $functionFile) {
|
||||||
$filesCode .= ' '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).",\n";
|
$filesCode .= ' ' . $fileIdentifier . ' => '
|
||||||
|
. $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$filesCode) {
|
if (!$filesCode) {
|
||||||
|
@ -584,8 +585,8 @@ REGISTER_LOADER;
|
||||||
if ($useIncludeFiles) {
|
if ($useIncludeFiles) {
|
||||||
$file .= <<<INCLUDE_FILES
|
$file .= <<<INCLUDE_FILES
|
||||||
\$includeFiles = require __DIR__ . '/autoload_files.php';
|
\$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
foreach (\$includeFiles as \$file) {
|
foreach (\$includeFiles as \$fileIdentifier => \$file) {
|
||||||
composerRequire$suffix(\$file);
|
composerRequire$suffix(\$fileIdentifier, \$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -603,17 +604,16 @@ METHOD_FOOTER;
|
||||||
return $file . <<<FOOTER
|
return $file . <<<FOOTER
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequire$suffix(\$file)
|
function composerRequire$suffix(\$fileIdentifier, \$file)
|
||||||
{
|
{
|
||||||
if (empty(\$GLOBALS['composerRequiredFiles'])) {
|
if (empty(\$GLOBALS['composerRequiredFiles'])) {
|
||||||
\$GLOBALS['composerRequiredFiles'] = array();
|
\$GLOBALS['composerRequiredFiles'] = array();
|
||||||
}
|
}
|
||||||
\$fileSignature = md5_file(\$file);
|
|
||||||
|
|
||||||
if (empty(\$GLOBALS['composerRequiredFiles'][\$fileSignature])) {
|
if (empty(\$GLOBALS['composerRequiredFiles'][\$fileIdentifier])) {
|
||||||
require \$file;
|
require \$file;
|
||||||
|
|
||||||
\$GLOBALS['composerRequiredFiles'][\$fileSignature] = true;
|
\$GLOBALS['composerRequiredFiles'][\$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +655,11 @@ FOOTER;
|
||||||
|
|
||||||
$relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
|
$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;
|
$autoloads[] = $relativePath;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -668,6 +672,11 @@ FOOTER;
|
||||||
return $autoloads;
|
return $autoloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getFileIdentifier($path)
|
||||||
|
{
|
||||||
|
return md5_file($path);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts packages by dependency weight
|
* Sorts packages by dependency weight
|
||||||
*
|
*
|
||||||
|
|
|
@ -1003,8 +1003,8 @@ EOF;
|
||||||
$this->assertEquals($expectedNamespace, file_get_contents($vendorDir.'/composer/autoload_namespaces.php'));
|
$this->assertEquals($expectedNamespace, file_get_contents($vendorDir.'/composer/autoload_namespaces.php'));
|
||||||
$this->assertEquals($expectedPsr4, file_get_contents($vendorDir.'/composer/autoload_psr4.php'));
|
$this->assertEquals($expectedPsr4, file_get_contents($vendorDir.'/composer/autoload_psr4.php'));
|
||||||
$this->assertEquals($expectedClassmap, file_get_contents($vendorDir.'/composer/autoload_classmap.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("\$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("\$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpLevelRelativePaths()
|
public function testUpLevelRelativePaths()
|
||||||
|
@ -1079,7 +1079,7 @@ EOF;
|
||||||
$this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
|
$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($expectedPsr4, file_get_contents($this->vendorDir.'/composer/autoload_psr4.php'));
|
||||||
$this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.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()
|
public function testEmptyPaths()
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$baseDir . '/foo.php',
|
'25b429360a61ca2629fdf9a4f484981c' => $baseDir . '/foo.php',
|
||||||
$baseDir . '/bar.php',
|
'524f65941cc9a0fa65ff0ec097ccde8a' => $baseDir . '/bar.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$baseDir . '/devfiles/foo.php',
|
'fc1e99cd93a6aa58e3b1565e688bcd87' => $baseDir . '/devfiles/foo.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,9 +6,9 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$vendorDir . '/a/a/test.php',
|
'b18a3c4a24b1dc69fdd96098e5c28e01' => $vendorDir . '/a/a/test.php',
|
||||||
$vendorDir . '/b/b/test2.php',
|
'93797e35718fdafb825b1fe25c08a92c' => $vendorDir . '/b/b/test2.php',
|
||||||
$vendorDir . '/c/c/foo/bar/test3.php',
|
'a57008eef928ced7c299bfea724d8441' => $vendorDir . '/c/c/foo/bar/test3.php',
|
||||||
$vendorDir . '/c/c/foo/bar/test4.php',
|
'32e13a06a803ac6553a93454bcd3d2da' => $vendorDir . '/c/c/foo/bar/test4.php',
|
||||||
$baseDir . '/root.php',
|
'504bb142db8acef729eeeb06b0aedec5' => $baseDir . '/root.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$baseDir . '/foo.php',
|
'25b429360a61ca2629fdf9a4f484981c' => $baseDir . '/foo.php',
|
||||||
$baseDir . '/bar.php',
|
'524f65941cc9a0fa65ff0ec097ccde8a' => $baseDir . '/bar.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,24 +41,23 @@ class ComposerAutoloaderInitFilesAutoloadOrder
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
foreach ($includeFiles as $file) {
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
composerRequireFilesAutoloadOrder($file);
|
composerRequireFilesAutoloadOrder($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequireFilesAutoloadOrder($file)
|
function composerRequireFilesAutoloadOrder($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
$GLOBALS['composerRequiredFiles'] = array();
|
||||||
}
|
}
|
||||||
$fileSignature = md5_file($file);
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileSignature])) {
|
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileSignature] = true;
|
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,24 +41,23 @@ class ComposerAutoloaderInitFilesAutoload
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
foreach ($includeFiles as $file) {
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
composerRequireFilesAutoload($file);
|
composerRequireFilesAutoload($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequireFilesAutoload($file)
|
function composerRequireFilesAutoload($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
$GLOBALS['composerRequiredFiles'] = array();
|
||||||
}
|
}
|
||||||
$fileSignature = md5_file($file);
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileSignature])) {
|
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileSignature] = true;
|
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,16 +65,15 @@ class ComposerAutoloaderInitIncludePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequireIncludePath($file)
|
function composerRequireIncludePath($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
$GLOBALS['composerRequiredFiles'] = array();
|
||||||
}
|
}
|
||||||
$fileSignature = md5_file($file);
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileSignature])) {
|
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileSignature] = true;
|
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ class ComposerAutoloaderInitTargetDir
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
foreach ($includeFiles as $file) {
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
composerRequireTargetDir($file);
|
composerRequireTargetDir($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
|
@ -69,16 +69,15 @@ class ComposerAutoloaderInitTargetDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequireTargetDir($file)
|
function composerRequireTargetDir($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
$GLOBALS['composerRequiredFiles'] = array();
|
||||||
}
|
}
|
||||||
$fileSignature = md5_file($file);
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileSignature])) {
|
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileSignature] = true;
|
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue