1
0
Fork 0
pull/151/head
digitalkaoz 2012-02-05 12:42:04 +01:00
commit b5b0337ed0
5 changed files with 39 additions and 3 deletions

View File

@ -54,7 +54,7 @@ EOF;
$filesystem = new Filesystem(); $filesystem = new Filesystem();
$vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/'); $vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/');
$relVendorPath = ltrim(substr($vendorPath, strlen(getcwd())), '/'); $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath);
$vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); $vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
$namespacesFile = <<<EOF $namespacesFile = <<<EOF
@ -93,7 +93,12 @@ EOF;
$path = strtr($path, '\\', '/'); $path = strtr($path, '\\', '/');
$baseDir = ''; $baseDir = '';
if (!$filesystem->isAbsolutePath($path)) { if (!$filesystem->isAbsolutePath($path)) {
if (strpos($path, $relVendorPath) === 0) { // vendor dir == working dir
if (preg_match('{^(\./?)?$}', $relVendorPath)) {
$path = '/'.$path;
$baseDir = '$vendorDir . ';
} elseif (strpos($path, $relVendorPath) === 0) {
// path starts with vendor dir
$path = substr($path, strlen($relVendorPath)); $path = substr($path, strlen($relVendorPath));
$baseDir = '$vendorDir . '; $baseDir = '$vendorDir . ';
} else { } else {

View File

@ -937,7 +937,7 @@ class Solver
$this->installedMap[$package->getId()] = $package; $this->installedMap[$package->getId()] = $package;
} }
if (version_compare(PHP_VERSION, '5.3.2', '>')) { if (version_compare(PHP_VERSION, '5.3.3', '>')) {
$this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1); $this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1);
} else { } else {
$this->decisionMap = array_fill(0, $this->pool->getMaxId() + 1, 0); $this->decisionMap = array_fill(0, $this->pool->getMaxId() + 1, 0);

View File

@ -53,6 +53,9 @@ class PearRepository extends ArrayRepository
foreach ($categories as $category) { foreach ($categories as $category) {
$categoryLink = $category->getAttribute("xlink:href"); $categoryLink = $category->getAttribute("xlink:href");
$categoryLink = str_replace("info.xml", "packages.xml", $categoryLink); $categoryLink = str_replace("info.xml", "packages.xml", $categoryLink);
if ('/' !== substr($categoryLink, 0, 1)) {
$categoryLink = '/' . $categoryLink;
}
$packagesXML = $this->requestXml($this->url . $categoryLink); $packagesXML = $this->requestXml($this->url . $categoryLink);
$packages = $packagesXML->getElementsByTagName('p'); $packages = $packagesXML->getElementsByTagName('p');

View File

@ -77,6 +77,24 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase
$this->assertAutoloadFiles('main', $this->vendorDir.'/.composer'); $this->assertAutoloadFiles('main', $this->vendorDir.'/.composer');
} }
public function testVendorDirSameAsWorkingDir()
{
$this->vendorDir = $this->workingDir;
$package = new MemoryPackage('a', '1.0', '1.0');
$package->setAutoload(array('psr-0' => array('Main' => 'src/', 'Lala' => 'src/')));
$this->repo->expects($this->once())
->method('getPackages')
->will($this->returnValue(array()));
if (!is_dir($this->vendorDir.'/.composer')) {
mkdir($this->vendorDir.'/.composer', 0777, true);
}
$this->generator->dump($this->repo, $package, $this->im, $this->vendorDir.'/.composer');
$this->assertAutoloadFiles('main3', $this->vendorDir.'/.composer');
}
public function testMainPackageAutoloadingAlternativeVendorDir() public function testMainPackageAutoloadingAlternativeVendorDir()
{ {
$package = new MemoryPackage('a', '1.0', '1.0'); $package = new MemoryPackage('a', '1.0', '1.0');

View File

@ -0,0 +1,10 @@
<?php
// autoload_namespace.php generated by Composer
$vendorDir = dirname(__DIR__);
return array(
'Main' => $vendorDir . '/src/',
'Lala' => $vendorDir . '/src/',
);