Browse Source

Avoid ambiguity warning for example directories as well

In particular, PEAR repositories use a classmap and example directories trigger
multiple false positive warnings.
Denis Sokolov 11 years ago
parent
commit
836534067b

+ 1 - 1
src/Composer/Autoload/ClassMapGenerator.php

@@ -84,7 +84,7 @@ class ClassMapGenerator
             foreach ($classes as $class) {
                 if (!isset($map[$class])) {
                     $map[$class] = $filePath;
-                } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
+                } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
                     $io->write(
                         '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
                         ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'

+ 1 - 1
tests/Composer/Test/Autoload/ClassMapGeneratorTest.php

@@ -170,7 +170,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
             "
         );
 
-        foreach (array('test', 'fixture') as $keyword) {
+        foreach (array('test', 'fixture', 'example') as $keyword) {
             if (!is_dir($tempDir.'/'.$keyword)) {
                 mkdir($tempDir.'/'.$keyword, 0777, true);
             }