protected function resolveNamespace(array $token_info, $classname)
    {
        // Resolve the namespace based on the use directive.
        if (isset($token_info['use'])
            && !empty($token_info['use'])
            && strpos($classname, DIRECTORY_SEPARATOR) === false) {
            foreach ($token_info['use'] as $use) {
                if (strpos($use, "\\{$classname}") === false) {
                    continue;
                }

                return $use;
            }
        }

        // Prefix the classname with the class namespace if defined.
        if (isset($token_info['namespace'])) {
            $classname = $token_info['namespace'] . "\\$classname";
        }

        return $classname;
    }