Browse Source

Merge branch '1.6'

Jordi Boggiano 6 years ago
parent
commit
4ebb747e12

+ 1 - 0
bin/composer

@@ -5,6 +5,7 @@ if (PHP_SAPI !== 'cli') {
     echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
 }
 
+setlocale(LC_ALL, 'C');
 require __DIR__.'/../src/bootstrap.php';
 
 use Composer\Console\Application;

+ 4 - 0
src/Composer/Autoload/ClassMapGenerator.php

@@ -179,6 +179,10 @@ class ClassMapGenerator
         if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
             $contents = substr($contents, 0, $pos);
         }
+        // strip comments if short open tags are in the file
+        if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
+            $contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
+        }
 
         preg_match_all('{
             (?:

+ 12 - 1
src/Composer/Installer/LibraryInstaller.php

@@ -18,6 +18,7 @@ use Composer\Repository\InstalledRepositoryInterface;
 use Composer\Package\PackageInterface;
 use Composer\Util\Filesystem;
 use Composer\Util\Silencer;
+use Composer\Util\Platform;
 
 /**
  * Package installation manager.
@@ -71,7 +72,17 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
      */
     public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
     {
-        return $repo->hasPackage($package) && is_readable($this->getInstallPath($package));
+        if (!$repo->hasPackage($package)) {
+            return false;
+        }
+
+        $installPath = $this->getInstallPath($package);
+
+        if (is_readable($installPath)) {
+            return true;
+        }
+
+        return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
     }
 
     /**

+ 4 - 0
src/Composer/Util/Filesystem.php

@@ -103,6 +103,10 @@ class Filesystem
             return $this->removeJunction($directory);
         }
 
+        if (is_link($directory)) {
+            return unlink($directory);
+        }
+
         if (!file_exists($directory) || !is_dir($directory)) {
             return true;
         }

+ 3 - 3
tests/Composer/Test/Autoload/AutoloadGeneratorTest.php

@@ -1334,10 +1334,10 @@ EOF;
 
         file_put_contents($this->workingDir.'/forks/bar/src/exclude/FooExclClass.php', '<?php class FooExclClass {};');
         $target = $this->workingDir.'/forks/bar/';
-        $link = $this->workingDir.'/composersrc/foo/bar/';
+        $link = $this->workingDir.'/composersrc/foo/bar';
         $command = Platform::isWindows()
-            ? 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target)
-            : 'ln -s "' . $target . '" "' . $link;
+            ? 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target) . '"'
+            : 'ln -s "' . $target . '" "' . $link . '"';
         exec($command);
 
         $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');

+ 0 - 8
tests/Composer/Test/Autoload/ClassMapGeneratorTest.php

@@ -62,14 +62,6 @@ class ClassMapGeneratorTest extends TestCase
             'ShortOpenTagDocblock' => realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php',
         );
 
-        /**
-         * @wontfix If short_open_tag is not enabled, we end up parsing the docblock because
-         *  php_strip_whitespace won't recognize the file. Funky edge-case (does not apply to HHVM).
-         */
-        if (!defined('HHVM_VERSION') && !ini_get('short_open_tag')) {
-            $classmap['description'] = realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php';
-        }
-
         $data = array(
             array(__DIR__ . '/Fixtures/Namespaced', array(
                 'Namespaced\\Bar' => realpath(__DIR__) . '/Fixtures/Namespaced/Bar.inc',

+ 1 - 0
tests/Composer/Test/Autoload/Fixtures/classmap/ShortOpenTagDocblock.php

@@ -2,4 +2,5 @@
 /**
  * Some class description here.
  */
+// other class name in comment
 class ShortOpenTagDocblock {}