No Description

Declaration.php 984B

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