2017-08-18 22:57:27 +02:00
|
|
|
<?php declare(strict_types=1);
|
2014-12-19 17:21:46 +01:00
|
|
|
|
|
|
|
namespace PhpParser\Builder;
|
|
|
|
|
|
|
|
use PhpParser;
|
2017-04-24 21:15:11 +02:00
|
|
|
use PhpParser\BuilderHelpers;
|
2014-12-19 17:21:46 +01:00
|
|
|
|
2017-04-24 21:15:11 +02:00
|
|
|
abstract class Declaration implements PhpParser\Builder
|
2014-12-19 17:21:46 +01:00
|
|
|
{
|
2017-08-13 14:06:08 +02:00
|
|
|
protected $attributes = [];
|
2014-12-19 17:21:46 +01:00
|
|
|
|
|
|
|
abstract public function addStmt($stmt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds multiple statements.
|
|
|
|
*
|
|
|
|
* @param array $stmts The statements to add
|
|
|
|
*
|
|
|
|
* @return $this The builder instance (for fluid interface)
|
|
|
|
*/
|
|
|
|
public function addStmts(array $stmts) {
|
|
|
|
foreach ($stmts as $stmt) {
|
|
|
|
$this->addStmt($stmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets doc comment for the declaration.
|
|
|
|
*
|
|
|
|
* @param PhpParser\Comment\Doc|string $docComment Doc comment to set
|
|
|
|
*
|
|
|
|
* @return $this The builder instance (for fluid interface)
|
|
|
|
*/
|
|
|
|
public function setDocComment($docComment) {
|
2017-08-13 14:06:08 +02:00
|
|
|
$this->attributes['comments'] = [
|
2017-04-24 21:15:11 +02:00
|
|
|
BuilderHelpers::normalizeDocComment($docComment)
|
2017-08-13 14:06:08 +02:00
|
|
|
];
|
2014-12-19 17:21:46 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|