1
0
Fork 0

Fix traits on 5.3 and handling of empty namespace blocks

pull/1311/head
Jordi Boggiano 2012-11-10 17:58:18 +01:00
parent 8e9678a5ba
commit 4c3e7802a4
1 changed files with 3 additions and 2 deletions

View File

@ -93,9 +93,10 @@ class ClassMapGenerator
private static function findClasses($path) private static function findClasses($path)
{ {
$contents = php_strip_whitespace($path); $contents = php_strip_whitespace($path);
$traits = version_compare(PHP_VERSION, '5.4', '<') ? '' : '|trait';
try { try {
if (!preg_match('{\b(?:class|interface|trait)\b}i', $contents)) { if (!preg_match('{\b(?:class|interface'.$traits.')\b}i', $contents)) {
return array(); return array();
} }
@ -104,7 +105,7 @@ class ClassMapGenerator
// strip strings // strip strings
$contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}', 'null', $contents); $contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}', 'null', $contents);
preg_match_all('{(?:\b(?<![\$:>])(?<type>class|interface|trait)\s+(?<name>\S+)|\b(?<![\$:>])(?<ns>namespace)\s+(?<nsname>[^\s;{}\\\\]+(?:\s*\\\\\s*[^\s;{}\\\\]+)*))}i', $contents, $matches); preg_match_all('{(?:\b(?<![\$:>])(?<type>class|interface'.$traits.')\s+(?<name>\S+)|\b(?<![\$:>])(?<ns>namespace)(?<nsname>\s+[^\s;{}\\\\]+(?:\s*\\\\\s*[^\s;{}\\\\]+)*|\s*\{))}i', $contents, $matches);
$classes = array(); $classes = array();
$namespace = ''; $namespace = '';