Update ClassMapGenerator to work better with symlinks, fixes #7252, closes #7251

main
Petr /Peggy/ Sládek 6 years ago committed by Jordi Boggiano
parent 72476b62d4
commit 8d06832077

@ -94,6 +94,10 @@ class ClassMapGenerator
if ($blacklist && preg_match($blacklist, strtr(realpath($filePath), '\\', '/'))) {
continue;
}
// check non-realpath of file for directories symlink in project dir
if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
continue;
}
$classes = self::findClasses($filePath);

@ -23,6 +23,7 @@ use Composer\Repository\InstalledRepositoryInterface;
use Composer\Installer\InstallationManager;
use Composer\Config;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Platform;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
class AutoloadGeneratorTest extends TestCase
@ -1292,6 +1293,7 @@ EOF;
),
'classmap' => array('composersrc/'),
'exclude-from-classmap' => array(
'/composersrc/foo/bar/',
'/composersrc/excludedTests/',
'/composersrc/ClassToExclude.php',
'/composersrc/*/excluded/excsubpath',
@ -1326,6 +1328,18 @@ EOF;
file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/foo.php', '<?php class ClassExcludeMapFoo2 {}');
file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/bar.php', '<?php class ClassExcludeMapBar {}');
// symlink directory in project directory in classmap
$this->fs->ensureDirectoryExists($this->workingDir.'/forks/bar/src/exclude');
$this->fs->ensureDirectoryExists($this->workingDir.'/composersrc/foo');
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/';
$command = Platform::isWindows()
? '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');
// Assert that autoload_classmap.php was correctly generated.

Loading…
Cancel
Save