public function unresolveName($name)
{
if (in_array(strtolower($name), ['self', 'parent', 'array', 'callable', 'string', 'bool', 'float', 'int', ''], TRUE)) {
return $name;
}
$name = ltrim($name, '\\');
$res = NULL;
$lower = strtolower($name);
foreach ($this->uses as $alias => $for) {
if (Strings::startsWith($lower . '\\', strtolower($for) . '\\')) {
$short = $alias . substr($name, strlen($for));
if (!isset($res) || strlen($res) > strlen($short)) {
$res = $short;
}
}
}
if (!$res && Strings::startsWith($lower, strtolower($this->name) . '\\')) {
return substr($name, strlen($this->name) + 1);
} else {
return $res ?: ($this->name ? '\\' : '') . $name;
}
}