2014-02-06 14:44:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpParser\Node;
|
|
|
|
|
2014-03-26 18:23:30 +01:00
|
|
|
use PhpParser\Error;
|
2014-02-06 14:44:16 +01:00
|
|
|
use PhpParser\NodeAbstract;
|
|
|
|
|
|
|
|
/**
|
2014-03-26 18:23:30 +01:00
|
|
|
* @property null|string|Name $type Typehint
|
|
|
|
* @property bool $byRef Whether is passed by reference
|
|
|
|
* @property bool $variadic Whether this is a variadic argument
|
|
|
|
* @property string $name Name
|
|
|
|
* @property null|Expr $default Default value
|
2014-02-06 14:44:16 +01:00
|
|
|
*/
|
|
|
|
class Param extends NodeAbstract
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Constructs a parameter node.
|
|
|
|
*
|
|
|
|
* @param string $name Name
|
|
|
|
* @param null|Expr $default Default value
|
|
|
|
* @param null|string|Name $type Typehint
|
|
|
|
* @param bool $byRef Whether is passed by reference
|
2014-03-26 18:23:30 +01:00
|
|
|
* @param bool $variadic Whether this is a variadic argument
|
2014-02-06 14:44:16 +01:00
|
|
|
* @param array $attributes Additional attributes
|
|
|
|
*/
|
2014-03-26 18:23:30 +01:00
|
|
|
public function __construct($name, $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
|
2014-02-06 14:44:16 +01:00
|
|
|
parent::__construct(
|
|
|
|
array(
|
2014-03-26 18:23:30 +01:00
|
|
|
'type' => $type,
|
|
|
|
'byRef' => $byRef,
|
|
|
|
'variadic' => $variadic,
|
|
|
|
'name' => $name,
|
|
|
|
'default' => $default,
|
2014-02-06 14:44:16 +01:00
|
|
|
),
|
|
|
|
$attributes
|
|
|
|
);
|
2014-03-26 18:23:30 +01:00
|
|
|
|
|
|
|
if ($variadic && null !== $default) {
|
|
|
|
throw new Error('Variadic parameter cannot have a default value');
|
|
|
|
}
|
2014-02-06 14:44:16 +01:00
|
|
|
}
|
|
|
|
}
|