Exemplo n.º 1
0
 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])) {
         $name->setFirst($this->aliases[Stmt\Use_::TYPE_NORMAL][$aliasName]);
     } elseif ($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])) {
             // resolve unqualified aliases
             $name->set($this->aliases[$type][$aliasName]);
         } else {
             // unqualified, unaliased names cannot be resolved at compile-time
             return $name;
         }
     } elseif (null !== $this->namespace) {
         // if no alias exists prepend current namespace
         $name->prepend($this->namespace);
     }
     return new Name\FullyQualified($name->parts, $name->getAttributes());
 }