Chris@0: name = $name; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Extends one or more interfaces. Chris@0: * Chris@0: * @param Name|string ...$interfaces Names of interfaces to extend Chris@0: * Chris@0: * @return $this The builder instance (for fluid interface) Chris@0: */ Chris@0: public function extend() { Chris@0: foreach (func_get_args() as $interface) { Chris@0: $this->extends[] = $this->normalizeName($interface); Chris@0: } Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Adds a statement. Chris@0: * Chris@0: * @param Stmt|PhpParser\Builder $stmt The statement to add Chris@0: * Chris@0: * @return $this The builder instance (for fluid interface) Chris@0: */ Chris@0: public function addStmt($stmt) { Chris@0: $stmt = $this->normalizeNode($stmt); Chris@0: Chris@0: $type = $stmt->getType(); Chris@0: switch ($type) { Chris@0: case 'Stmt_ClassConst': Chris@0: $this->constants[] = $stmt; Chris@0: break; Chris@0: Chris@0: case 'Stmt_ClassMethod': Chris@0: // we erase all statements in the body of an interface method Chris@0: $stmt->stmts = null; Chris@0: $this->methods[] = $stmt; Chris@0: break; Chris@0: Chris@0: default: Chris@0: throw new \LogicException(sprintf('Unexpected node of type "%s"', $type)); Chris@0: } Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the built interface node. Chris@0: * Chris@0: * @return Stmt\Interface_ The built interface node Chris@0: */ Chris@0: public function getNode() { Chris@0: return new Stmt\Interface_($this->name, array( Chris@0: 'extends' => $this->extends, Chris@0: 'stmts' => array_merge($this->constants, $this->methods), Chris@0: ), $this->attributes); Chris@0: } Chris@0: }