tokens = token_get_all('tokens); $key = key($this->tokens); // FIXME this workaround should be dropped while ( $token && $token[0] === T_STRING && isset($this->tokens[$key + 2]) && $this->tokens[++$key] === '-' && $this->tokens[++$key][0] === T_STRING ) { $token[1] .= '-' . $this->tokens[$key][1]; next($this->tokens); next($this->tokens); } } while (is_array($token) && $token[0] === T_WHITESPACE); if (is_string($token) || $token === false) { $this->token_type = $token; $this->token_value = null; } else { $this->token_type = $token[0]; $this->token_value = match ($token[0]) { T_CONSTANT_ENCAPSED_STRING => stripcslashes(substr($token[1], 1, -1)), T_DNUMBER => (double) $token[1], T_LNUMBER => (int) $token[1], default => $token[1], }; } return $this->token_type; } /** * Returns the current token type. The valid token types are * those defined for token_get_all() in the PHP documentation. */ public function tokenType(): mixed { return $this->token_type; } /** * Returns the current token value if the token type supports * a value (T_STRING, T_LNUMBER etc.). Returns null otherwise. */ public function tokenValue(): mixed { return $this->token_value; } }