-<?php
+<?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser;
+use PhpParser\BuilderHelpers;
use PhpParser\Node;
-class Param extends PhpParser\BuilderAbstract
+class Param implements PhpParser\Builder
{
protected $name;
*
* @param string $name Name of the parameter
*/
- public function __construct($name) {
+ public function __construct(string $name) {
$this->name = $name;
}
* @return $this The builder instance (for fluid interface)
*/
public function setDefault($value) {
- $this->default = $this->normalizeValue($value);
+ $this->default = BuilderHelpers::normalizeValue($value);
return $this;
}
* @return $this The builder instance (for fluid interface)
*/
public function setTypeHint($type) {
- $this->type = $this->normalizeType($type);
- if ($this->type === 'void') {
+ $this->type = BuilderHelpers::normalizeType($type);
+ if ($this->type == 'void') {
throw new \LogicException('Parameter type cannot be void');
}
*
* @return Node\Param The built parameter node
*/
- public function getNode() {
+ public function getNode() : Node {
return new Node\Param(
- $this->name, $this->default, $this->type, $this->byRef, $this->variadic
+ new Node\Expr\Variable($this->name),
+ $this->default, $this->type, $this->byRef, $this->variadic
);
}
}