|
@@ -107,21 +107,27 @@ class ClassMapGenerator
|
|
|
throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);
|
|
|
}
|
|
|
|
|
|
- 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
|
|
|
$contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}', 'null', $contents);
|
|
|
+ // keep only php code
|
|
|
+ $phpContents = preg_match_all('{<\?(?:php)?(.*)\?>}s', $contents, $m) ? join($m[1], ' ') : '';
|
|
|
+ $contents = preg_replace('{<\?(php)?.*\?>}s', '', $contents);
|
|
|
+ if (preg_match('{<\?(?:php)?(.*)}s', $contents, $m)) {
|
|
|
+ $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', $contents, $matches);
|
|
|
+ }ix', $phpContents, $matches);
|
|
|
$classes = array();
|
|
|
|
|
|
$namespace = '';
|