Browse Source

Fix issues in new autoloader code

Jordi Boggiano 13 years ago
parent
commit
8a571c05db

+ 1 - 19
src/Composer/Autoload/AutoloadGenerator.php

@@ -90,14 +90,12 @@ EOF;
     {
         $installPaths = array();
         foreach ($this->localRepo->getPackages() as $package) {
-            $this->populateAutoloadInformation($package);
-
             $installPaths[] = array(
                 $package,
                 $this->installationManager->getInstallPath($package)
             );
         }
-        $installPaths[] = array($package, '');
+        $installPaths[] = array($this->package, '');
 
         $autoloads = array();
         foreach ($installPaths as $item) {
@@ -108,7 +106,6 @@ EOF;
             }
 
             foreach ($package->getAutoload() as $type => $mapping) {
-                $autoloads[$type] = isset($autoloads[$type]) ? $autoloads[$type] : array();
                 $autoloads[$type][] = array(
                     'mapping'   => $mapping,
                     'path'      => $installPath,
@@ -118,19 +115,4 @@ EOF;
 
         return $autoloads;
     }
-
-    /**
-     * Because remote repos don't include the autoload data,
-     * we have to manually fetch it from the locally installed
-     * packages.
-     */
-    private function populateAutoloadInformation(PackageInterface $package)
-    {
-        $path = $this->installationManager->getInstallPath($package);
-
-        $loader = new JsonLoader();
-        $fullPackage = $loader->load(new JsonFile($path.'/composer.json'));
-
-        $package->setAutoload($fullPackage->getAutoload());
-    }
 }

+ 3 - 1
src/Composer/Package/Dumper/ArrayDumper.php

@@ -44,7 +44,9 @@ class ArrayDumper
 
         $data = array();
         $data['name'] = $package->getPrettyName();
-        $data['target-dir'] = $package->getTargetDir();
+        if ($package->getTargetDir()) {
+            $data['target-dir'] = $package->getTargetDir();
+        }
         foreach ($keys as $key) {
             $getter = 'get'.ucfirst($key);
             $value  = $package->$getter();

+ 3 - 3
tests/Composer/Test/Installer/LibraryInstallerTest.php

@@ -78,7 +78,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
         $this->dm
             ->expects($this->once())
             ->method('download')
-            ->with($package, $this->dir.DIRECTORY_SEPARATOR.'some/package');
+            ->with($package, $this->dir.'/some/package');
 
         $this->repository
             ->expects($this->once())
@@ -108,7 +108,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
         $this->dm
             ->expects($this->once())
             ->method('update')
-            ->with($initial, $target, $this->dir.DIRECTORY_SEPARATOR.'package1');
+            ->with($initial, $target, $this->dir.'/package1');
 
         $this->repository
             ->expects($this->once())
@@ -146,7 +146,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
         $this->dm
             ->expects($this->once())
             ->method('remove')
-            ->with($package, $this->dir.DIRECTORY_SEPARATOR.'pkg');
+            ->with($package, $this->dir.'/pkg');
 
         $this->repository
             ->expects($this->once())