Browse Source

Merge remote-tracking branch 'digitalkaoz/classmap_generator_finder'

Jordi Boggiano 11 years ago
parent
commit
7b81d51a38
2 changed files with 3 additions and 7 deletions
  1. 1 1
      composer.json
  2. 2 6
      src/Composer/Autoload/ClassMapGenerator.php

+ 1 - 1
composer.json

@@ -26,7 +26,7 @@
         "justinrainbow/json-schema": "1.1.*",
         "seld/jsonlint": "1.*",
         "symfony/console": "~2.3@dev",
-        "symfony/finder": "~2.1",
+        "symfony/finder": "~2.2",
         "symfony/process": "~2.1@dev"
     },
     "require-dev": {

+ 2 - 6
src/Composer/Autoload/ClassMapGenerator.php

@@ -12,6 +12,7 @@
  */
 
 namespace Composer\Autoload;
+use Symfony\Component\Finder\Finder;
 
 /**
  * ClassMapGenerator
@@ -53,7 +54,7 @@ class ClassMapGenerator
             if (is_file($path)) {
                 $path = array(new \SplFileInfo($path));
             } elseif (is_dir($path)) {
-                $path = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+                $path = Finder::create()->useBestAdapter()->files()->followLinks()->name('/\.(php|inc)$/')->in($path);
             } else {
                 throw new \RuntimeException(
                     'Could not scan for classes inside "'.$path.
@@ -65,10 +66,6 @@ class ClassMapGenerator
         $map = array();
 
         foreach ($path as $file) {
-            if (!$file->isFile()) {
-                continue;
-            }
-
             $filePath = $file->getRealPath();
 
             if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc'))) {
@@ -84,7 +81,6 @@ class ClassMapGenerator
             foreach ($classes as $class) {
                 $map[$class] = $filePath;
             }
-
         }
 
         return $map;