Chris@13: name = $name; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets default value for the parameter. Chris@0: * Chris@0: * @param mixed $value Default value to use Chris@0: * Chris@0: * @return $this The builder instance (for fluid interface) Chris@0: */ Chris@0: public function setDefault($value) { Chris@13: $this->default = BuilderHelpers::normalizeValue($value); Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@17: * Sets type for the parameter. Chris@0: * Chris@17: * @param string|Node\Name|Node\NullableType $type Parameter type Chris@0: * Chris@0: * @return $this The builder instance (for fluid interface) Chris@0: */ Chris@17: public function setType($type) { Chris@13: $this->type = BuilderHelpers::normalizeType($type); Chris@13: if ($this->type == 'void') { Chris@0: throw new \LogicException('Parameter type cannot be void'); Chris@0: } Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@17: * Sets type for the parameter. Chris@17: * Chris@17: * @param string|Node\Name|Node\NullableType $type Parameter type Chris@17: * Chris@17: * @return $this The builder instance (for fluid interface) Chris@17: * Chris@17: * @deprecated Use setType() instead Chris@17: */ Chris@17: public function setTypeHint($type) { Chris@17: return $this->setType($type); Chris@17: } Chris@17: Chris@17: /** Chris@0: * Make the parameter accept the value by reference. Chris@0: * Chris@0: * @return $this The builder instance (for fluid interface) Chris@0: */ Chris@0: public function makeByRef() { Chris@0: $this->byRef = true; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Make the parameter variadic Chris@0: * Chris@0: * @return $this The builder instance (for fluid interface) Chris@0: */ Chris@0: public function makeVariadic() { Chris@0: $this->variadic = true; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the built parameter node. Chris@0: * Chris@0: * @return Node\Param The built parameter node Chris@0: */ Chris@13: public function getNode() : Node { Chris@0: return new Node\Param( Chris@13: new Node\Expr\Variable($this->name), Chris@13: $this->default, $this->type, $this->byRef, $this->variadic Chris@0: ); Chris@0: } Chris@0: }