grom358 / pharborist

A PHP library to query and transform source code via tree operations.
GNU General Public License v3.0
44 stars 10 forks source link

Fatal error from calling firstChild() of TokenNode in IdentifierNameTrait #181

Closed phenaproxima closed 10 years ago

phenaproxima commented 10 years ago

DMU is getting fatals from this method of IdentifierNameTrait:

  /**
   * Set the identifier name of this node.
   *
   * @param string $name
   *   New name.
   * @return $this
   */
  public function setName($name) {
    /** @var TokenNode $identifier */
    $identifier = $this->name->firstChild();
    $identifier->setText($name);
    return $this;
  }

TokenNode hasn't got a firstChild() method since it doesn't implement ParentNodeInterface. So this fatal results:

Call to undefined method Pharborist\TokenNode::firstChild() in /path/to/pharborist/src/Namespaces/IdentifierNameTrait.php, line 40