Up-level relative paths in exclude-from-classmap
parent
2a8a9a4592
commit
4046ae042d
|
@ -697,8 +697,25 @@ FOOTER;
|
||||||
// add support for wildcards * and **
|
// add support for wildcards * and **
|
||||||
$path = str_replace('\\*\\*', '.+?', $path);
|
$path = str_replace('\\*\\*', '.+?', $path);
|
||||||
$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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1084,6 +1084,7 @@ EOF;
|
||||||
'psr-4' => array('Acme\Foo\\' => '../path/../src-psr4'),
|
'psr-4' => array('Acme\Foo\\' => '../path/../src-psr4'),
|
||||||
'classmap' => array('../classmap'),
|
'classmap' => array('../classmap'),
|
||||||
'files' => array('../test.php'),
|
'files' => array('../test.php'),
|
||||||
|
'exclude-from-classmap' => array('./../classmap/excluded'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->repository->expects($this->once())
|
$this->repository->expects($this->once())
|
||||||
|
@ -1091,9 +1092,10 @@ EOF;
|
||||||
->will($this->returnValue(array()));
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
$this->fs->ensureDirectoryExists($this->workingDir.'/src/Foo');
|
$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.'/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/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 {}');
|
file_put_contents($this->workingDir.'/test.php', '<?php class Foo {}');
|
||||||
|
|
||||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_14');
|
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_14');
|
||||||
|
|
Loading…
Reference in New Issue