1 <?php declare(strict_types=1);
3 namespace PhpParser\Node;
5 use PhpParser\NodeAbstract;
7 class Param extends NodeAbstract
9 /** @var null|Identifier|Name|NullableType Typehint */
11 /** @var bool Whether parameter is passed by reference */
13 /** @var bool Whether this is a variadic argument */
15 /** @var Expr\Variable|Expr\Error Parameter variable */
17 /** @var null|Expr Default value */
21 * Constructs a parameter node.
23 * @param Expr\Variable|Expr\Error $var Parameter variable
24 * @param null|Expr $default Default value
25 * @param null|string|Name|NullableType $type Typehint
26 * @param bool $byRef Whether is passed by reference
27 * @param bool $variadic Whether this is a variadic argument
28 * @param array $attributes Additional attributes
30 public function __construct(
31 $var, Expr $default = null, $type = null,
32 bool $byRef = false, bool $variadic = false, array $attributes = []
34 parent::__construct($attributes);
35 $this->type = \is_string($type) ? new Identifier($type) : $type;
36 $this->byRef = $byRef;
37 $this->variadic = $variadic;
39 $this->default = $default;
42 public function getSubNodeNames() : array {
43 return ['type', 'byRef', 'variadic', 'var', 'default'];
46 public function getType() : string {