Declaration.php 934 B

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