Chris@13: 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@13: public function extend(...$interfaces) { Chris@13: foreach ($interfaces as $interface) { Chris@13: $this->extends[] = BuilderHelpers::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@13: $stmt = BuilderHelpers::normalizeNode($stmt); Chris@0: Chris@13: if ($stmt instanceof Stmt\ClassConst) { Chris@13: $this->constants[] = $stmt; Chris@13: } elseif ($stmt instanceof Stmt\ClassMethod) { Chris@13: // we erase all statements in the body of an interface method Chris@13: $stmt->stmts = null; Chris@13: $this->methods[] = $stmt; Chris@13: } else { Chris@13: throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); 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@13: public function getNode() : PhpParser\Node { Chris@13: return new Stmt\Interface_($this->name, [ Chris@0: 'extends' => $this->extends, Chris@0: 'stmts' => array_merge($this->constants, $this->methods), Chris@13: ], $this->attributes); Chris@0: } Chris@13: }