Debian Codegraph @

vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php

raw
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 /** @var array<string, mixed> */
10 protected array $attributes = [];
11
12 /**
13 * Adds a statement.
14 *
15 * @param PhpParser\Node\Stmt|PhpParser\Builder $stmt The statement to add
16 *
17 * @return $this The builder instance (for fluid interface)
18 */
19 abstract public function addStmt($stmt);
20
21 /**
22 * Adds multiple statements.
23 *
24 * @param (PhpParser\Node\Stmt|PhpParser\Builder)[] $stmts The statements to add
25 *
26 * @return $this The builder instance (for fluid interface)
27 */
28 public function addStmts(array $stmts) {
29 foreach ($stmts as $stmt) {
30 $this->addStmt($stmt);
31 }
32
33 return $this;
34 }
35
36 /**
37 * Sets doc comment for the declaration.
38 *
39 * @param PhpParser\Comment\Doc|string $docComment Doc comment to set
40 *
41 * @return $this The builder instance (for fluid interface)
42 */
43 public function setDocComment($docComment) {
44 $this->attributes['comments'] = [
45 BuilderHelpers::normalizeDocComment($docComment)
46 ];
47
48 return $this;
49 }
50 }