Ignore classes in ClassMapGenerator
parent
29c39cc266
commit
05d9912f97
|
@ -184,8 +184,9 @@ EOF;
|
|||
preg_quote($dir),
|
||||
($psrType === 'psr-0' && strpos($namespace, '_') === false) ? preg_quote(strtr($namespace, '\\', '/')) : ''
|
||||
);
|
||||
foreach (ClassMapGenerator::createMap($dir, $whitelist, $this->io) as $class => $path) {
|
||||
if ('' === $namespace || 0 === strpos($class, $namespace)) {
|
||||
|
||||
$namespaceFilter = $namespace === '' ? null : $namespace;
|
||||
foreach (ClassMapGenerator::createMap($dir, $whitelist, $this->io, $namespaceFilter) as $class => $path) {
|
||||
if (!isset($classMap[$class])) {
|
||||
$path = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
|
||||
$classMap[$class] = $path.",\n";
|
||||
|
@ -195,7 +196,6 @@ EOF;
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($autoloads['classmap'] as $dir) {
|
||||
foreach (ClassMapGenerator::createMap($dir, null, $this->io) as $class => $path) {
|
||||
|
|
|
@ -46,12 +46,14 @@ class ClassMapGenerator
|
|||
*
|
||||
* @param \Iterator|string $path The path to search in or an iterator
|
||||
* @param string $whitelist Regex that matches against the file path
|
||||
* @param IOInterface $io IO object
|
||||
* @param string $namespace Optional namespace prefix to filter by
|
||||
*
|
||||
* @return array A class map array
|
||||
*
|
||||
* @throws \RuntimeException When the path is neither an existing file nor directory
|
||||
*/
|
||||
public static function createMap($path, $whitelist = null, IOInterface $io = null)
|
||||
public static function createMap($path, $whitelist = null, IOInterface $io = null, $namespace = null)
|
||||
{
|
||||
if (is_string($path)) {
|
||||
if (is_file($path)) {
|
||||
|
@ -82,6 +84,11 @@ class ClassMapGenerator
|
|||
$classes = self::findClasses($filePath);
|
||||
|
||||
foreach ($classes as $class) {
|
||||
// skip classes not within the given namespace prefix
|
||||
if (null !== $namespace && 0 !== strpos($class, $namespace)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($map[$class])) {
|
||||
$map[$class] = $filePath;
|
||||
} elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
|
||||
|
|
Loading…
Reference in New Issue