Declaration.php 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace PhpParser\Builder;
  3. use PhpParser;
  4. use PhpParser\Node;
  5. use PhpParser\Node\Stmt;
  6. abstract class Declaration extends PhpParser\BuilderAbstract
  7. {
  8. protected $attributes = array();
  9. abstract public function addStmt($stmt);
  10. /**
  11. * Adds multiple statements.
  12. *
  13. * @param array $stmts The statements to add
  14. *
  15. * @return $this The builder instance (for fluid interface)
  16. */
  17. public function addStmts(array $stmts) {
  18. foreach ($stmts as $stmt) {
  19. $this->addStmt($stmt);
  20. }
  21. return $this;
  22. }
  23. /**
  24. * Sets doc comment for the declaration.
  25. *
  26. * @param PhpParser\Comment\Doc|string $docComment Doc comment to set
  27. *
  28. * @return $this The builder instance (for fluid interface)
  29. */
  30. public function setDocComment($docComment) {
  31. $this->attributes['comments'] = array(
  32. $this->normalizeDocComment($docComment)
  33. );
  34. return $this;
  35. }
  36. }