NEW Support namespace tokens in ClassInfo::parse_class_spec()

The T_NAME_QUALIFIED and T_NAME_FULLY_QUALIFIED tokens are introduced
in PHP 8, and encapsulate theentire FQCN, replacing the previous
structure of a group of T_STRINGs and T_NS_SEPARATORs.
This commit is contained in:
Garion Herman 2020-08-29 12:08:24 +12:00
parent af40eee3ad
commit 08010d5933
1 changed files with 7 additions and 1 deletions

View File

@ -439,7 +439,13 @@ class ClassInfo
$tokenName = is_array($token) ? $token[0] : $token;
// Get the class name
if ($class === null && is_array($token) && $token[0] === T_STRING) {
if (\defined('T_NAME_QUALIFIED') && is_array($token) &&
($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)
) {
// PHP 8 exposes the FQCN as a single T_NAME_QUALIFIED or T_NAME_FULLY_QUALIFIED token
$class .= $token[1];
$hadNamespace = true;
} elseif ($class === null && is_array($token) && $token[0] === T_STRING) {
$class = $token[1];
} elseif (is_array($token) && $token[0] === T_NS_SEPARATOR) {
$class .= $token[1];