Param   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubNodeNames() 0 3 1
A __construct() 0 12 3
1
<?php
2
3
namespace PhpParser\Node;
4
5
use PhpParser\Error;
6
use PhpParser\NodeAbstract;
7
8
class Param extends NodeAbstract
9
{
10
    /** @var null|string|Name Typehint */
11
    public $type;
12
    /** @var bool Whether parameter is passed by reference */
13
    public $byRef;
14
    /** @var bool Whether this is a variadic argument */
15
    public $variadic;
16
    /** @var string Name */
17
    public $name;
18
    /** @var null|Expr Default value */
19
    public $default;
20
21
    /**
22
     * Constructs a parameter node.
23
     *
24
     * @param string           $name       Name
25
     * @param null|Expr        $default    Default value
26
     * @param null|string|Name $type       Typehint
27
     * @param bool             $byRef      Whether is passed by reference
28
     * @param bool             $variadic   Whether this is a variadic argument
29
     * @param array            $attributes Additional attributes
30
     */
31
    public function __construct($name, Expr $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
32
        parent::__construct($attributes);
33
        $this->type = $type;
34
        $this->byRef = $byRef;
35
        $this->variadic = $variadic;
36
        $this->name = $name;
37
        $this->default = $default;
38
39
        if ($variadic && null !== $default) {
40
            throw new Error('Variadic parameter cannot have a default value', $default->getAttributes());
41
        }
42
    }
43
44
    public function getSubNodeNames() {
45
        return array('type', 'byRef', 'variadic', 'name', 'default');
46
    }
47
}
48