This method returns a new instance of the same type as the original and with the same
attributes.
If the slice is empty, null is returned. The null value will be correctly handled in
concatenations using concat().
Offset and length have the same meaning as in array_slice().
protected function resolveOtherName(Name $name, $type) { // fully qualified names are already resolved if ($name->isFullyQualified()) { return $name; } // resolve aliases for qualified names $aliasName = strtolower($name->getFirst()); if ($name->isQualified() && isset($this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName])) { $alias = $this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName]; return FullyQualified::concat($alias, $name->slice(1), $name->getAttributes()); } if ($name->isUnqualified()) { if ($type === Stmt\Use_::TYPE_CONSTANT) { // constant aliases are case-sensitive, function aliases case-insensitive $aliasName = $name->getFirst(); } if (!isset($this->aliases[$type][$aliasName])) { // unqualified, unaliased names cannot be resolved at compile-time return $name; } // resolve unqualified aliases return new FullyQualified($this->aliases[$type][$aliasName], $name->getAttributes()); } if (null !== $this->namespace) { // if no alias exists prepend current namespace return FullyQualified::concat($this->namespace, $name, $name->getAttributes()); } return new FullyQualified($name->parts, $name->getAttributes()); }