Chris@13: name = $name; 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@0: if ($stmt instanceof Stmt\Property) { Chris@0: $this->properties[] = $stmt; Chris@13: } elseif ($stmt instanceof Stmt\ClassMethod) { Chris@0: $this->methods[] = $stmt; Chris@13: } elseif ($stmt instanceof Stmt\TraitUse) { Chris@0: $this->uses[] = $stmt; Chris@0: } else { Chris@0: 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 trait node. Chris@0: * Chris@0: * @return Stmt\Trait_ The built interface node Chris@0: */ Chris@13: public function getNode() : PhpParser\Node { Chris@0: return new Stmt\Trait_( Chris@13: $this->name, [ Chris@0: 'stmts' => array_merge($this->uses, $this->properties, $this->methods) Chris@13: ], $this->attributes Chris@0: ); Chris@0: } Chris@0: }