1
0
Fork 0

autoload_files.php should return an array of files, instead of directly including them.

pull/2139/head
Andreas Hennings 2013-08-01 15:42:30 +02:00
parent 8e9bdfb4da
commit 5369904dd3
9 changed files with 41 additions and 25 deletions

View File

@ -300,13 +300,12 @@ EOF;
$filesCode = ''; $filesCode = '';
$files = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($files)); $files = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($files));
foreach ($files as $functionFile) { foreach ($files as $functionFile) {
$filesCode .= 'require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n"; $filesCode .= ' '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).",\n";
} }
if (!$filesCode) { if (!$filesCode) {
return FALSE; return FALSE;
} }
$filesCode = rtrim($filesCode);
return <<<EOF return <<<EOF
<?php <?php
@ -316,7 +315,8 @@ EOF;
\$vendorDir = $vendorPathCode; \$vendorDir = $vendorPathCode;
\$baseDir = $appBaseDirCode; \$baseDir = $appBaseDirCode;
$filesCode return array(
$filesCode);
EOF; EOF;
} }
@ -457,7 +457,9 @@ REGISTER_LOADER;
if ($useIncludeFiles) { if ($useIncludeFiles) {
$file .= <<<INCLUDE_FILES $file .= <<<INCLUDE_FILES
require __DIR__ . '/autoload_files.php'; foreach (require __DIR__ . '/autoload_files.php' as \$file) {
require \$file;
}
INCLUDE_FILES; INCLUDE_FILES;

View File

@ -755,8 +755,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($expectedClassmap, file_get_contents($vendorDir.'/composer/autoload_classmap.php')); $this->assertEquals($expectedClassmap, file_get_contents($vendorDir.'/composer/autoload_classmap.php'));
$this->assertContains("require \$vendorDir . '/b/b/bootstrap.php';", file_get_contents($vendorDir.'/composer/autoload_files.php')); $this->assertContains("\n \$vendorDir . '/b/b/bootstrap.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
$this->assertContains("require \$baseDir . '/test.php';", file_get_contents($vendorDir.'/composer/autoload_files.php')); $this->assertContains("\n \$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
} }
public function testUpLevelRelativePaths() public function testUpLevelRelativePaths()
@ -815,7 +815,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($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php')); $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
$this->assertContains("require \$baseDir . '/../test.php';", file_get_contents($this->vendorDir.'/composer/autoload_files.php')); $this->assertContains("\n \$baseDir . '/../test.php',\n", file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
} }
public function testEmptyPaths() public function testEmptyPaths()

View File

@ -5,5 +5,7 @@
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
require $baseDir . '/foo.php'; return array(
require $baseDir . '/bar.php'; $baseDir . '/foo.php',
$baseDir . '/bar.php',
);

View File

@ -5,9 +5,11 @@
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
require $vendorDir . '/c/lorem/testC.php'; return array(
require $vendorDir . '/z/foo/testA.php'; $vendorDir . '/c/lorem/testC.php',
require $vendorDir . '/d/d/testD.php'; $vendorDir . '/z/foo/testA.php',
require $vendorDir . '/b/bar/testB.php'; $vendorDir . '/d/d/testD.php',
require $vendorDir . '/e/e/testE.php'; $vendorDir . '/b/bar/testB.php',
require $baseDir . '/root.php'; $vendorDir . '/e/e/testE.php',
$baseDir . '/root.php',
);

View File

@ -5,8 +5,10 @@
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
require $vendorDir . '/a/a/test.php'; return array(
require $vendorDir . '/b/b/test2.php'; $vendorDir . '/a/a/test.php',
require $vendorDir . '/c/c/foo/bar/test3.php'; $vendorDir . '/b/b/test2.php',
require $baseDir . '/root.php'; $vendorDir . '/c/c/foo/bar/test3.php',
require $vendorDir . '/c/c/foo/bar/test4.php'; $baseDir . '/root.php',
$vendorDir . '/c/c/foo/bar/test4.php',
);

View File

@ -5,5 +5,7 @@
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
require $baseDir . '/foo.php'; return array(
require $baseDir . '/bar.php'; $baseDir . '/foo.php',
$baseDir . '/bar.php',
);

View File

@ -38,7 +38,9 @@ class ComposerAutoloaderInitFilesAutoloadOrder
$loader->register(true); $loader->register(true);
require __DIR__ . '/autoload_files.php'; foreach (require __DIR__ . '/autoload_files.php' as $file) {
require $file;
}
return $loader; return $loader;
} }

View File

@ -38,7 +38,9 @@ class ComposerAutoloaderInitFilesAutoload
$loader->register(true); $loader->register(true);
require __DIR__ . '/autoload_files.php'; foreach (require __DIR__ . '/autoload_files.php' as $file) {
require $file;
}
return $loader; return $loader;
} }

View File

@ -40,7 +40,9 @@ class ComposerAutoloaderInitTargetDir
$loader->register(true); $loader->register(true);
require __DIR__ . '/autoload_files.php'; foreach (require __DIR__ . '/autoload_files.php' as $file) {
require $file;
}
return $loader; return $loader;
} }