3 namespace PhpParser\Builder;
8 class Param extends PhpParser\BuilderAbstract
12 protected $default = null;
14 /** @var string|Node\Name|Node\NullableType|null */
15 protected $type = null;
17 protected $byRef = false;
20 * Creates a parameter builder.
22 * @param string $name Name of the parameter
24 public function __construct($name) {
29 * Sets default value for the parameter.
31 * @param mixed $value Default value to use
33 * @return $this The builder instance (for fluid interface)
35 public function setDefault($value) {
36 $this->default = $this->normalizeValue($value);
42 * Sets type hint for the parameter.
44 * @param string|Node\Name|Node\NullableType $type Type hint to use
46 * @return $this The builder instance (for fluid interface)
48 public function setTypeHint($type) {
49 $this->type = $this->normalizeType($type);
50 if ($this->type === 'void') {
51 throw new \LogicException('Parameter type cannot be void');
58 * Make the parameter accept the value by reference.
60 * @return $this The builder instance (for fluid interface)
62 public function makeByRef() {
69 * Returns the built parameter node.
71 * @return Node\Param The built parameter node
73 public function getNode() {
74 return new Node\Param(
75 $this->name, $this->default, $this->type, $this->byRef