Browse Source

Avoid tokenizing files for nothing

Jordi Boggiano 13 years ago
parent
commit
383c3f0153
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/Composer/Autoload/ClassMapGenerator.php

+ 3 - 0
src/Composer/Autoload/ClassMapGenerator.php

@@ -89,6 +89,9 @@ class ClassMapGenerator
     {
         $contents = file_get_contents($path);
         try {
+            if (!preg_match('{\b(?:class|interface|trait)\b}i', $contents)) {
+                return array();
+            }
             $tokens   = token_get_all($contents);
         } catch (\Exception $e) {
             throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);