Support generating class map for XHP classes
parent
68e910d92a
commit
57d9e9852d
|
@ -136,7 +136,7 @@ class ClassMapGenerator
|
||||||
|
|
||||||
preg_match_all('{
|
preg_match_all('{
|
||||||
(?:
|
(?:
|
||||||
\b(?<![\$:>])(?P<type>class|interface'.$traits.') \s+ (?P<name>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)
|
\b(?<![\$:>])(?P<type>class|interface'.$traits.') \s+ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:]*)
|
||||||
| \b(?<![\$:>])(?P<ns>namespace) (?P<nsname>\s+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\s*\\\\\s*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*)? \s*[\{;]
|
| \b(?<![\$:>])(?P<ns>namespace) (?P<nsname>\s+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\s*\\\\\s*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*)? \s*[\{;]
|
||||||
)
|
)
|
||||||
}ix', $contents, $matches);
|
}ix', $contents, $matches);
|
||||||
|
@ -148,7 +148,12 @@ class ClassMapGenerator
|
||||||
if (!empty($matches['ns'][$i])) {
|
if (!empty($matches['ns'][$i])) {
|
||||||
$namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
|
$namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
|
||||||
} else {
|
} else {
|
||||||
$classes[] = ltrim($namespace . $matches['name'][$i], '\\');
|
$name = $matches['name'][$i];
|
||||||
|
if ($name[0] === ':') {
|
||||||
|
// This is an XHP class, https://github.com/facebook/xhp
|
||||||
|
$name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
|
||||||
|
}
|
||||||
|
$classes[] = ltrim($namespace . $name, '\\');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue