1
0
Fork 0

Up-level relative paths in exclude-from-classmap

pull/4607/head
Omer Karadagli 2015-11-12 00:32:02 +00:00
parent 2a8a9a4592
commit 4046ae042d
2 changed files with 21 additions and 2 deletions

View File

@ -697,8 +697,25 @@ FOOTER;
// add support for wildcards * and **
$path = str_replace('\\*\\*', '.+?', $path);
$path = str_replace('\\*', '[^/]+?', $path);
// add support for up-level relative paths
$path = preg_replace_callback(
'{^((\\\.{1,2})+)/}',
function ($matches) use (&$updir) {
if (isset($matches[1])) {
// undo preg_quote for the matched string
$updir = str_replace('\\.', '.', $matches[1]);
}
$autoloads[] = empty($installPath) ? preg_quote(strtr(getcwd(), '\\', '/')) . '/' . $path : preg_quote($installPath) . '/' . $path;
return '';
},
$path
);
if (empty($installPath)) {
$installPath = strtr(getcwd(), '\\', '/');
}
$resolvedPath = realpath($installPath . '/' . $updir);
$autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path;
continue;
}

View File

@ -1084,6 +1084,7 @@ EOF;
'psr-4' => array('Acme\Foo\\' => '../path/../src-psr4'),
'classmap' => array('../classmap'),
'files' => array('../test.php'),
'exclude-from-classmap' => array('./../classmap/excluded'),
));
$this->repository->expects($this->once())
@ -1091,9 +1092,10 @@ EOF;
->will($this->returnValue(array()));
$this->fs->ensureDirectoryExists($this->workingDir.'/src/Foo');
$this->fs->ensureDirectoryExists($this->workingDir.'/classmap');
$this->fs->ensureDirectoryExists($this->workingDir.'/classmap/excluded');
file_put_contents($this->workingDir.'/src/Foo/Bar.php', '<?php namespace Foo; class Bar {}');
file_put_contents($this->workingDir.'/classmap/classes.php', '<?php namespace Foo; class Foo {}');
file_put_contents($this->workingDir.'/classmap/excluded/classes.php', '<?php namespace Foo; class Boo {}');
file_put_contents($this->workingDir.'/test.php', '<?php class Foo {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_14');