function NameContext::getShortName
Get shortest representation of this fully-qualified name.
Parameters
string $name Fully-qualified name (without leading namespace separator):
Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*:
Return value
Name Shortest representation
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ NameContext.php, line 212
Class
Namespace
PhpParserCode
public function getShortName(string $name, int $type) : Name {
$possibleNames = $this->getPossibleNames($name, $type);
// Find shortest name
$shortestName = null;
$shortestLength = \INF;
foreach ($possibleNames as $possibleName) {
$length = strlen($possibleName->toCodeString());
if ($length < $shortestLength) {
$shortestName = $possibleName;
$shortestLength = $length;
}
}
return $shortestName;
}