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