Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Restore early return to happen as early as possible

  • Loading branch information...
commit bd72e3765b1132447a99834cf714220f76b62cbc 1 parent 8a0c856
@Seldaek Seldaek authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/Composer/Autoload/ClassMapGenerator.php
View
12 src/Composer/Autoload/ClassMapGenerator.php
@@ -107,6 +107,11 @@ private static function findClasses($path)
throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);
}
+ // return early if there is no chance of matching anything in this file
+ if (!preg_match('{\b(?:class|interface'.$traits.')\b}i', $contents)) {
+ return array();
+ }
+
// strip heredocs/nowdocs
$contents = preg_replace('{<<<\'?(\w+)\'?(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\1(?=\r\n|\n|\r|;)}s', 'null', $contents);
// strip strings
@@ -118,18 +123,14 @@ private static function findClasses($path)
$phpContents .= ' ' . $m[1];
}
- if (!preg_match('{\b(?:class|interface'.$traits.')\b}i', $phpContents)) {
- return array();
- }
-
preg_match_all('{
(?:
\b(?<![\$:>])(?<type>class|interface'.$traits.') \s+ (?<name>\S+)
| \b(?<![\$:>])(?<ns>namespace) (?<nsname>\s+[^\s;{}\\\\]+(?:\s*\\\\\s*[^\s;{}\\\\]+)*)? \s*[\{;]
)
}ix', $phpContents, $matches);
- $classes = array();
+ $classes = array();
$namespace = '';
for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
@@ -141,6 +142,5 @@ private static function findClasses($path)
}
return $classes;
-
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.