12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php declare(strict_types=1);
- namespace PhpParser\Builder;
- use PhpParser;
- use PhpParser\BuilderHelpers;
- use PhpParser\Node;
- use PhpParser\Node\Stmt;
- class Function_ extends FunctionLike
- {
- protected $name;
- protected $stmts = [];
-
- protected $attributeGroups = [];
-
- public function __construct(string $name) {
- $this->name = $name;
- }
-
- public function addStmt($stmt) {
- $this->stmts[] = BuilderHelpers::normalizeStmt($stmt);
- return $this;
- }
-
- public function addAttribute($attribute) {
- $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute);
- return $this;
- }
-
- public function getNode() : Node {
- return new Stmt\Function_($this->name, [
- 'byRef' => $this->returnByRef,
- 'params' => $this->params,
- 'returnType' => $this->returnType,
- 'stmts' => $this->stmts,
- 'attrGroups' => $this->attributeGroups,
- ], $this->attributes);
- }
- }
|