2017-08-18 22:57:27 +02:00
|
|
|
<?php declare(strict_types=1);
|
2014-02-06 14:44:16 +01:00
|
|
|
|
|
|
|
namespace PhpParser\Node;
|
|
|
|
|
|
|
|
use PhpParser\NodeAbstract;
|
|
|
|
|
|
|
|
class Param extends NodeAbstract
|
|
|
|
{
|
2017-04-28 19:09:39 +02:00
|
|
|
/** @var null|Identifier|Name|NullableType Typehint */
|
2015-02-28 18:44:28 +01:00
|
|
|
public $type;
|
|
|
|
/** @var bool Whether parameter is passed by reference */
|
|
|
|
public $byRef;
|
|
|
|
/** @var bool Whether this is a variadic argument */
|
|
|
|
public $variadic;
|
2018-05-12 19:49:39 +02:00
|
|
|
/** @var Expr\Variable|Expr\Error Parameter variable */
|
2017-01-19 23:38:40 +01:00
|
|
|
public $var;
|
2015-02-28 18:44:28 +01:00
|
|
|
/** @var null|Expr Default value */
|
|
|
|
public $default;
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
/**
|
|
|
|
* Constructs a parameter node.
|
|
|
|
*
|
2018-05-12 19:49:39 +02:00
|
|
|
* @param Expr\Variable|Expr\Error $var Parameter variable
|
2016-12-05 13:30:29 +01:00
|
|
|
* @param null|Expr $default Default value
|
|
|
|
* @param null|string|Name|NullableType $type Typehint
|
|
|
|
* @param bool $byRef Whether is passed by reference
|
|
|
|
* @param bool $variadic Whether this is a variadic argument
|
|
|
|
* @param array $attributes Additional attributes
|
2014-02-06 14:44:16 +01:00
|
|
|
*/
|
2017-01-19 23:32:49 +01:00
|
|
|
public function __construct(
|
2018-05-12 19:49:39 +02:00
|
|
|
$var, Expr $default = null, $type = null,
|
2017-08-13 14:06:08 +02:00
|
|
|
bool $byRef = false, bool $variadic = false, array $attributes = []
|
2017-01-19 23:32:49 +01:00
|
|
|
) {
|
2015-05-02 22:17:34 +02:00
|
|
|
parent::__construct($attributes);
|
2017-04-28 19:09:39 +02:00
|
|
|
$this->type = \is_string($type) ? new Identifier($type) : $type;
|
2015-02-28 18:44:28 +01:00
|
|
|
$this->byRef = $byRef;
|
|
|
|
$this->variadic = $variadic;
|
2017-01-19 23:38:40 +01:00
|
|
|
$this->var = $var;
|
2015-02-28 18:44:28 +01:00
|
|
|
$this->default = $default;
|
2014-02-06 14:44:16 +01:00
|
|
|
}
|
2015-02-28 18:44:28 +01:00
|
|
|
|
2017-04-28 21:40:59 +02:00
|
|
|
public function getSubNodeNames() : array {
|
2017-08-13 14:06:08 +02:00
|
|
|
return ['type', 'byRef', 'variadic', 'var', 'default'];
|
2015-02-28 18:44:28 +01:00
|
|
|
}
|
2017-11-12 21:25:57 +01:00
|
|
|
|
2018-01-10 18:57:48 +01:00
|
|
|
public function getType() : string {
|
2017-11-12 21:25:57 +01:00
|
|
|
return 'Param';
|
|
|
|
}
|
2015-02-28 18:44:28 +01:00
|
|
|
}
|