public function setAlias($alias) {
    if (is_string($alias)) {
      $alias = new TokenNode(T_STRING, $alias);
    }

    if ($alias instanceof TokenNode) {
      if ($this->hasAlias()) {
        $this->alias->replaceWith($alias);
      }
      else {
        $this->alias = $alias;
        $this->addChild(WhitespaceNode::create(' '));
        $this->addChild(Token::_as());
        $this->addChild(WhitespaceNode::create(' '));
        $this->addChild($alias, 'alias');
      }
    }
    elseif ($alias === NULL && $this->hasAlias()) {
      $this->alias->previousUntil(Filter::isInstanceOf('\Pharborist\Namespaces\NameNode'))->remove();
      $this->alias->remove();
      $this->alias = NULL;
    }
    else {
      throw new \InvalidArgumentException();
    }

    return $this;
  }
public function setAlias($alias) {
    if (is_string($alias)) {
      $alias = new TokenNode(T_STRING, $alias);
    }

    if ($alias instanceof TokenNode) {
      if ($this->hasAlias()) {
        $this->alias->replaceWith($alias);
      }
      else {
        $this->alias = $alias;
        $this->addChild(WhitespaceNode::create(' '));
        $this->addChild(Token::_as());
        $this->addChild(WhitespaceNode::create(' '));
        $this->addChild($alias, 'alias');
      }
    }
    elseif ($alias === NULL && $this->hasAlias()) {
      $this->alias->previousUntil(Filter::isInstanceOf('\Pharborist\Namespaces\NameNode'))->remove();
      $this->alias->remove();
      $this->alias = NULL;
    }
    else {
      throw new \InvalidArgumentException();
    }

    return $this;
  }
public function setAlias ( $ alias ) { if ( is_string ( $ alias ) ) { $ alias = new TokenNode ( T_STRING , $ alias ) ; } if ( $ alias instanceof TokenNode ) { if ( $ this -> hasAlias ( ) ) { $ this -> alias -> replaceWith ( $ alias ) ; } else { $ this -> alias = $ alias ; $ this -> addChild ( WhitespaceNode :: create ( ' ' ) ) ; $ this -> addChild ( Token :: _as ( ) ) ; $ this -> addChild ( WhitespaceNode :: create ( ' ' ) ) ; $ this -> addChild ( $ alias , 'alias' ) ; } } elseif ( $ alias === NULL && $ this -> hasAlias ( ) ) { $ this -> alias -> previousUntil ( Filter :: isInstanceOf ( '\Pharborist\Namespaces\NameNode' ) ) -> remove ( ) ; $ this -> alias -> remove ( ) ; $ this -> alias = NULL ; } else { throw new \ InvalidArgumentException ( ) ; } return $ this ; }
Sets the imported item's alias. If NULL is passed, the alias is removed.

@param \Pharborist\TokenNode|string|NULL $alias

@return $this
Sets the imported item s alias . If NULL is passed the alias is removed .