Fix traits on 5.3 and handling of empty namespace blocks
parent
8e9678a5ba
commit
4c3e7802a4
|
@ -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 = '';
|
||||||
|
|
Loading…
Reference in New Issue