1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php declare(strict_types=1);
- namespace PhpParser\Builder;
- use PhpParser\BuilderHelpers;
- use PhpParser\Node;
- abstract class FunctionLike extends Declaration
- {
- protected $returnByRef = false;
- protected $params = [];
-
- protected $returnType = null;
-
- public function makeReturnByRef() {
- $this->returnByRef = true;
- return $this;
- }
-
- public function addParam($param) {
- $param = BuilderHelpers::normalizeNode($param);
- if (!$param instanceof Node\Param) {
- throw new \LogicException(sprintf('Expected parameter node, got "%s"', $param->getType()));
- }
- $this->params[] = $param;
- return $this;
- }
-
- public function addParams(array $params) {
- foreach ($params as $param) {
- $this->addParam($param);
- }
- return $this;
- }
-
- public function setReturnType($type) {
- $this->returnType = BuilderHelpers::normalizeType($type);
- return $this;
- }
- }
|